<template>
	<view class="container2">


		<!--内容-->
		<view class="scroll" :style="{height: scrollHeight,marginTop:scrollTop}" touch-action: none>
			<!-- class="chat-content boxlist" -->
			<!-- :scroll-into-view="scrollViewId"   -->
			<scroll-view ref="scrollView" scroll-y="true" :scroll-into-view="scrollIntoView"
				:scroll-with-animation="true" :style="{height: scrollHeight,width:'100%'}" :scroll-top="scrollPageTop"
				touch-action: none>
				<checkbox-group @change="checkboxChange">
					<view class="message-box" v-for="(message, index) in listData" :key="index" :id="'msg_'+index">
						<view v-if="is_more" style="width: 30px;height: 30px;margin: 0 5px;">
							<checkbox :value="message" :checked="message.multiSelect" />
						</view>

						<view :class="message.from1==fromUserId?'message-item':'message-item1'"
							:style="{'width':is_more? 'calc(100% - 40px)':'100%'}">
							<view
								v-if="message.from1!=fromUserId && (message.contentType != 91 &&  message.contentType != 90)"
								@tap="toinformation(message.from1)">
								<image class="name-img" v-if="message.userAvatar" :src="message.userAvatar"></image>
								<view class="name-img" v-else-if="message.nickname.length > 0">
									{{message.nickname.slice(0,1)}}
								</view>
								<view class="name-img" v-else></view>
							</view>

							<!-- <view class="" v-if="message.contentType == 91"
								style="width: 100%;text-align: center;margin: 0px;">
								{{message.nickname}}{{message.dataContent}}
							</view>
							<view class="" v-else-if="message.contentType == 90"
								style="width: 100%;text-align: center;margin: 0px;">
								{{message.nickname}}{{message.dataContent}}
							</view> -->
							<!-- v-else -->
							<view :style="{'flex': '1','display': 'flex','align-items': 'flex-end'}">

								<!-- <image v-if="message.is_read == 1 && message.from1==fromUserId" class="" src="../../static/img/img_read.jpg" mode="aspectFit" style="width: 20px;height: 20px;margin: 0 10px;position: relative;"></image> -->

								<view :class="message.from1==fromUserId?'message-body self':'message-body self1'"
									v-if="message.contentType == 0" @tap="handleDirlog($event,message)">
									<view class="message-text">{{message.dataContent}}</view>
									<view class="message-time">{{message.time}}</view>
								</view>

								<view :class="message.from1==fromUserId?'message-img':'message-img1'"
									v-else-if="message.contentType == 1">
									<image
										:src="message.dataContent.indexOf('http') >= 0? message.dataContent : 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message.from1 + '&need_dump=0&file_name=th_' + message.dataContent"
										mode="aspectFill"
										style="position: relative;width: calc(70vw - 110rpx);height: calc(70vw - 110rpx);border-radius: 10px;"
										@tap="handleDirlog($event,message)"></image>
								</view>

								<view :class="message.from1==fromUserId?' self-video':' self-video1'"
									v-else-if="message.contentType == 6"
									:style="{'height': `${getSwiperHeight(message)}px`}">


									<image @tap="handleDirlog($event,message)"
										v-if="message.dataContent.width < message.dataContent.height"
										:src="'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message.from1 + '&need_dump=1&file_name=' + message.dataContent.fileMd5+'.jpg'"
										mode="widthFix"
										:style="{'position': 'relative','width':'60%','height': '100%','border-radius': '10px','margin-left':message.from1==fromUserId?'40%':'0'}">

									</image>
									<image @tap="handleDirlog($event,message)" v-else
										:src="'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message.from1 + '&need_dump=1&file_name=' + message.dataContent.fileMd5+'.jpg'"
										mode="widthFix"
										:style="{'position': 'relative','width':'100%','height': '100%','border-radius': '10px'}">

									</image>
									<image @tap="handleDirlog($event,message)"
										v-if="message.dataContent.width < message.dataContent.height"
										src="../../static/chat/video-play.png"
										:style="{'width': '30px','height': '30px','position': 'absolute','z-index': 2,'left': message.from1==fromUserId?'calc(30vw + calc(calc(70vw - 110rpx)*0.7) - 15px':'calc(calc(70vw - 110rpx)*0.3 + 55px)',}">

									</image>
									<image @tap="handleDirlog($event,message)" v-else
										src="../../static/chat/video-play.png"
										:style="{'width': '30px','height': '30px','position': 'absolute','z-index': 2,'left': message.from1==fromUserId?'calc(30vw + calc(calc(70vw - 110rpx)*0.5) - 15px)':'calc(calc(70vw - 110rpx)*0.5 + 55px)'}">

									</image>

								</view>
								<view :class="message.from1==fromUserId?'message-body self':'message-body self1'"
									v-else-if="message.contentType == 8" @tap="handleDirlog($event,message)">
									<view class="" style="display: flex;align-items: center;flex: 1;">
										<image class="" src="../../static/image/icon28@3x.png" mode="aspectFit"
											style="width: 30px;height: 30px;"></image>
										<view class="" style="flex: 1;margin-left: 5px;">
											<view class=""
												style="display: -webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden; text-overflow: ellipsis;line-height: 1.5;height: 1.5em;white-space: normal;word-break: break-all;">
												{{message.dataContent.name}}
											</view>
											<view class=""
												style="font-size: 12px;color: #999;display: -webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden; text-overflow: ellipsis;line-height: 1.5;height: 1.5em;white-space: normal;word-break: break-all;">
												{{message.dataContent.address}}
											</view>
										</view>
									</view>
								</view>
								<view :class="message.from1==fromUserId?'message-body self':'message-body self1'"
									v-else-if="message.contentType == 11" style="width: 80%"
									@tap="handleDirlog($event,message)">
									<view class="" style="display: flex;align-items: center;flex: 1;">
										<image v-if="message.dataContent.length > 0"
											:src="message.dataContent.pictures[0]" class="name-img1"></image>
										<view class="" style="flex: 1;margin-left: 5px;">
											<view class=""
												style="display: -webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden; text-overflow: ellipsis;line-height: 1.5;height: 1.5em;white-space: normal;word-break: break-all;">
												{{message.dataContent.title}}
											</view>
											<view class=""
												style="font-size: 12px;color: #999;display: -webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden; text-overflow: ellipsis;line-height: 1.5;height: 1.5em;white-space: normal;word-break: break-all;">
												{{message.dataContent.content}}
											</view>
										</view>
									</view>
									<view>
										<view class=""
											style="flex: 1;display: flex;justify-content: space-between;padding: 5px 10px;">
											<text
												style="font-size: 11px;color: #999;display: -webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden; text-overflow: ellipsis;line-height: 1.5;height: 1.5em;white-space: normal;word-break: break-all;">笔记</text>
											<text
												style="font-size: 11px;color: #999;display: -webkit-box;-webkit-box-orient: vertical; -webkit-line-clamp: 1;overflow: hidden; text-overflow: ellipsis;line-height: 1.5;height: 1.5em;white-space: normal;word-break: break-all;">{{message.time}}</text>
										</view>
									</view>
								</view>
								<view :class="message.from1==fromUserId?'message-body self':'message-body self1'"
									v-else>
									<view class="message-text">[暂不支持该消息类型]</view>
								</view>

							</view>

							<view
								v-if="message.from1==fromUserId && (message.contentType != 91 &&  message.contentType != 90)"
								@tap="toinformation(message.from1)">
								<image class="name-img" v-if="message.userAvatar" :src="message.userAvatar"></image>
								<view class="name-img" v-else-if="message.nickname.length > 0">
									{{message.nickname.slice(0,1)}}
								</view>
								<view class="name-img" v-else></view>
							</view>

						</view>

					</view>
				</checkbox-group>
			</scroll-view>
		</view>


		<view class="oper flex-row" @tap.stop="" v-if="is_send && info.g_status == 1">

			<image @tap="uploadImage" src="../../static/image/1@3x.png" class="icon"></image>
			<!--语音切换-->
			<view v-if="is_send" class="input-box" style="flex: 1;margin: 0 10px;">
				<input @focus="inputFocus" :focus="isFocus" :cursor-spacing="8" :adjust-position="false" type="text"
					v-model="content" class="input" placeholder="" @input="inputChange" />

				<view class="input-box-quote" v-if="JSON.stringify(quoteinfo) != '{}'">
					<!-- 0文字消息 1图片消息2语音留言消息3赠送的礼品消息4索取礼品消息5文件消息6短视频消息7名片消息8位置消息9实时音视频记录消息90系统消息或提示信息91消息撤回 -->

					<text>{{quoteinfo.nickname}}:</text>
					<text>{{quoteinfo.quote_content}}</text>

				</view>
			</view>


			<!--附件-->
			<view class="icon-send" :class="content ?'active':''" @touchend.prevent="sendgroup">
				<image src="../../static/image/send.png" class="" style="width: 20px;height: 20px;">
				</image>
			</view>
		</view>
		<view class="oper " style="width: 100%;text-align: center;justify-content: center;" @tap.stop=""
			v-else-if="info.g_status == -1">
			<text>临时聊天已结束</text>

		</view>

		<wxpup :wxPupData="wxPupData" @change="wxpupchange"></wxpup>


		<view class="video1" v-if="videoplay">
			<video id="myVideo" :enable-progress-gesture="true" show-fullscreen-btn="false" :src="videourl"
				controls="true" :autoplay="autoplay" @ended="ZhanTing" @error="continuePlay"></video>

			<!-- <video class="pics" id="myVideo" :style="videoStyle" objectFit="contain"
				:http-cache="true" :custom-cache="false" :autoplay="false" :muted="true" :show-mute-btn="true" :src="videourl"
				@loadedmetadata="onVideoLoaded" @ended="ZhanTing" @fullscreenchange="fullscreenchange"></video>	 -->
			<view class="btn-close-box ">

				<image class=" btn-close " @click="reback()" src="https://www.zwsmcn.com/jqshop/static/video-close.png"
					mode="aspectFit"></image>

			</view>
		</view>

		<u-popup :show="NotesShow" @close="NotesShow = false" mode="center" :round="10">
			<view class="" style="width: 90vw;height: 90vh; position: relative; padding: 30upx;">
				<view class="title-wrap">
					<view>笔记详情</view>
					<u-icon name="close" size=24 @tap="NotesShow=false"></u-icon>
				</view>
				<view class="uni-list"
					style="width: 100%;height: calc(100% - 50px); padding: 15px 0;position: relative;overflow-x: hidden;">
					<view>{{Notesinfo.title}}</view>
					<view> {{Notesinfo.content}}</view>
					<!-- <view style="display: flex;">
						
						<view>
							<view>热力服务站</view>
							<view>1栋一单元</view>
						</view>
					</view> -->
					<image v-for="item in Notesinfo.pictures" :src="item" style="width: 100%;" mode="widthFix"></image>

					<video id="myVideo" v-if="Notesinfo.vedio_url" :enable-progress-gesture="false"
						show-fullscreen-btn="false" :src="Notesinfo.vedio_url" controls="true" :autoplay="autoplay"
						@ended="ZhanTing" @error="continuePlay"
						style="width: calc(90vw - 30px);height:  100vw;"></video>
				</view>

			</view>
		</u-popup>
	</view>
</template>

<script>
	import emoji from '../../plugins/emoji.js'
	import {
		DB
	} from '@/util/sqlite/sqlite.js'
	import myVoice from '../../components/self-voice/index.vue'
	let EventType = require("./utils/event-type.js");
	let EventBus = require("./utils/event-bus.js");
	let ToolKits = require("./utils/toolkits.js");
	let imManager = require("./utils/im-manager.js");
	// import dbUtils from './dbUtils.js'  

	const innerAudioContext = uni.createInnerAudioContext()
	const recorderManager = uni.getRecorderManager()


	// const livekitPlugin = uni.requireNativePlugin('LivekitMeetingPlugin');

	import permision from "@/js_sdk/wa-permission/permission.js"




	export default {
		components: {
			myVoice,

		},
		data() {
			return {
				wxPupData: {},
				showMask: false,
				dirlogShow: false,
				img_index: 0,

				showtype: false,
				deltype: false,
				update_item: {},


				atMask: false,
				is_atmore: false,
				atList: [],

				voiceTitle: '按住 说话',

				is_more: false, ////多选
				is_more_image: false,
				more_list: [],
				checkedArray: [],



				emojis: [],
				isEdit: true,
				listData: [],
				isFocus: false,
				showEmoji: false,
				showFile: false,
				showVoice: false,
				scrollHeight: `calc(100vh  - 110upx)`, // 'auto', // 内容区域高度
				scrollTop: '0',
				statusBarHeight: 0, // 状态栏高度
				scrollViewId: '', // 滚动到最底部

				content: '',
				info: {},
				list: [

				],
				socketOpen: false,
				socketMsgQueue: [],
				fromUserId: '',
				fromUserFace: 'https://school.zwsmcn.com//static/user/img.png',


				toUserId: '',
				toUserName: '',

				timerId: '',


				isred: 0,
				reditem: {},
				packerState: 0,

				scrollIntoView: '',
				scrollPageTop: 0,
				isGroup: 0,

				AudioExam: null, //正在播放音频的实例
				AUDIO: uni.createInnerAudioContext(),
				playMsgid: null,
				VoiceTimer: null,
				recording: false, //标识是否正在录音
				isStopVoice: false, //加锁 防止点击过快引起的当录音正在准备(还没有开始录音)的时候,却调用了stop方法但并不能阻止录音的问题
				voiceInterval: null,
				voiceTime: 0, //总共录音时长
				canSend: true, //是否可以发送
				PointY: 0, //坐标位置
				voiceIconText: '正在录音...',

				firstFrameSrc: '',
				videourl: '',
				autoplay: false,
				videoplay: false,

				videoSrc: '',

				quoteinfo: {},
				Quicklist: [],

				originalArray: [],

				imageList: [],


				is_block: false,
				groupinfo: {},
				isForbid: false,

				NotesShow: false,
				Notesinfo: {},

				typeu: '',

				is_send: true,
			}
		},
		onLoad(option) {
			console.log(option);

			this.info.g_id = String(option.g_id)
			this.receiverInput = this.info.g_id;
			this.fromUserId = option.uid

			var loginInfo = {
				loginUserId: this.fromUserId,
				loginToken: '123456'
			};
			uni.setStorageSync('roomchat_loginInfo', loginInfo)
			uni.IMSDK.loginImpl(loginInfo, imManager.IM_SERVER_URL, false);



			// this.getchatlist()
			this.getDetail()


			// 注册im相关的应用层事件
			this.registerIMEvents();


			this.isGroup = 1;
			this.typeu = 44;





			// 初始化状态栏高度
			uni.getSystemInfo({
				success: res => {
					this.statusBarHeight = res.statusBarHeight
				}
			})

			// this.setScrollHeight(0)




			// 获取参数
			this.toUserId = option.toUserId
			this.toUserName = option.toUserName

			if(option.content){
				console.log(111)
				this.sendGroupMssage(option.content,0);
			}

		},
		onShow() {
			this.getchatlist()
		},
		onReady() {

		},
		onHide() {
			clearInterval(this.timerId);

		},
		onBackPress() {
			if (this.videoplay) {
				this.videoplay = false;
				return true
			} else if (this.showFile || this.showEmoji) {
				this.showFile = false
				this.showEmoji = false
				this.setScrollHeight(0)
				this.showDeleteEmojPop = false;
				return true
			}
			return false
		},
		computed: {
			// 自动筛选
			filteredList() {

				return this.btnlist.filter(item => item.isshow);
			}
		},
		methods: {
			updateInfo(info) {
				this.info = JSON.parse(info);

				console.log(this.info);
			},



			initAudio() {
				if (!this.audio) {
					this.audio = uni.createInnerAudioContext();
					this.audio.src = '../../static/mp3/play.mp3'; // 本地铃声路径
					this.audio.loop = false; // 循环播放
					this.audio.volume = 1.0; // 设置音量
				}
			},
			// 播放铃声
			playRingtone() {
				this.initAudio();
				this.audio.play();
				console.log('铃声开始播放');
			},
			// 停止铃声
			stopRingtone() {
				if (this.audio) {
					this.audio.stop();
					console.log('铃声停止播放');
				}
			},

			calculateDuration(duration_h) {

				let duration = Number(duration_h) / 1000;
				const hours = Math.floor((duration % 86400) / 3600) >= 10 ? Math.floor((duration % 86400) / 3600) : '0' +
					Math.floor((duration % 86400) / 3600); // 一小时有3600秒
				const minutes = Math.floor((duration % 3600) / 60) >= 10 ? Math.floor((duration % 3600) / 60) : '0' + Math
					.floor((duration % 3600) / 60); // 一分钟有60秒
				const seconds = Math.floor(duration % 60) >= 10 ? Math.floor(duration % 60) : '0' + Math.floor(duration %
					60);
				if (hours > 0) {
					return `${hours}:${minutes}:${seconds}`;
				} else if (minutes > 0) {
					return `${minutes}:${seconds}`;
				} else if (seconds > 0) {
					return `00:${seconds}`;
				}

			},
			// calc(calc(70vw - 110rpx)*1)
			getSwiperTop(message) {
				let url = 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message.from1 +
					'&need_dump=1&file_name=' + message.dataContent_img;

				uni.getImageInfo({
					src: url,
					success: (res) => {
						console.log(res);
						const screenWidth = uni.getSystemInfoSync().windowWidth;
						// calc(calc(70vw - 110rpx)*1)
						let top = (screenWidth * 0.7 - 55) / res.width * res.height;

						// console.log(screenWidth);
						// console.log((screenWidth.width*0.7));
						// console.log((screenWidth.width*0.7 - 55));
						// console.log(res.width);
						// console.log(res.height);
						console.log(top);
						return top
					}
				})

			},
			getSwiperHeight(message) {
				let url = 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message.from1 +
					'&need_dump=1&file_name=' + message.dataContent_img;

				uni.getImageInfo({
					src: url,
					success: (res) => {
						console.log(res);
						const screenWidth = uni.getSystemInfoSync().windowWidth;
						let swiperHeight = screenWidth / res.width * res.height * 2;
						console.log(swiperHeight);
						return swiperHeight
					}
				})

			},
			inputChange(e) {
				console.log(e);
				let str = e.detail.value
				let lastChar = str.slice(-1);
				console.log(lastChar);
				if (this.isGroup == 1 && lastChar == '@') {
					this.atMask = true
				}
				if (e.detail.value.indexOf('@') < 0) {
					this.atList = [];
				}
			},
			sendat(item) {
				console.log(item);
				this.content = this.content + item.nickname;
				this.atList.push(item.user_uid)
				this.atMask = false
				console.log(this.atList);
			},

			openMask() {
				// console.log('open');
			},
			closeMask() {
				this.updateMask = false
				// console.log('close');
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				})
			},

			async btnevent(index) {
				console.log(index);
				switch (index) {
					case 1:
						this.uploadImage()
						break
					case 2:
						this.uploadVideo();
						break
					case 3:
						console.log(this.receiverInput);

						this.showtype = true;

						break
					case 4:

						let permisionID = '';
						permisionID = 'android.permission.RECORD_AUDIO';
						var result = await permision.requestAndroidPermission(permisionID)
						var strStatus
						if (result == 1) {
							strStatus = "已获得授权"
							this.getLocation();
						} else if (result == 0) {
							strStatus = "未获得授权"
						} else {
							strStatus = "被永久拒绝权限"
							uni.showModal({
								content: permisionID + strStatus,
								showCancel: false
							});
						}


						break

					case 5:
						this.navTo('/pages/mine/shop/myNotes?type=1')
						break
					case 6:
						this.navTo('/pages/index/chosefriend?type=1')
						break
					case 7:
						this.navTo('/pages/mine/shop/myCollect?type=1')
						break
					case 8:
						this.showMask = true;
						break

					case 9:
						this.uploadFile();
						break
					case 10:

						console.log(this.receiverInput);
						this.navTo('/pages/index/redpacket?receiver=' + this.receiverInput + '&isGroup=' + this
							.isGroup)
						break
					case 11:
						this.navTo('/pages/index/transfer?receiver=' + this.receiverInput + '&isGroup=' + this.isGroup)
						break
				}
			},
			async btnVoice() {
				let permisionID = '';
				permisionID = 'android.permission.RECORD_AUDIO';
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus = '';
				if (result == 1) {
					strStatus = "已获得授权"
					livekitPlugin.callSingleVoice({
						"id": this.receiverInput
					});
				} else if (result == 0) {
					strStatus = "未获得授权"
					console.log(strStatus)
				} else {
					strStatus = "被永久拒绝权限"
					uni.showModal({
						content: permisionID + strStatus,
						showCancel: false
					});
				}


			},
			async btnVideo() {

				let permisionID = '';
				permisionID = 'android.permission.CAMERA';
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus = '';
				if (result == 1) {
					strStatus = "已获得授权"

					permisionID = 'android.permission.RECORD_AUDIO';
					result = await permision.requestAndroidPermission(permisionID)
					strStatus = '';
					if (result == 1) {
						strStatus = "已获得授权"
						livekitPlugin.callSingleVideo({
							"id": this.receiverInput
						});
					} else if (result == 0) {
						strStatus = "未获得授权"
						console.log(strStatus)
					} else {
						strStatus = "被永久拒绝权限"
						uni.showModal({
							content: permisionID + strStatus,
							showCancel: false
						});
					}

				} else if (result == 0) {
					strStatus = "未获得授权"
					console.log(strStatus)
				} else {
					strStatus = "被永久拒绝权限"
					uni.showModal({
						content: permisionID + strStatus,
						showCancel: false
					});
				}


			},




			sendQuick(item) {
				this.sendGroupMssage(item.content, 0)
				this.showMask = false

			},

			receiveQrcode() {

				uni.showLoading();
				this.disabled = true;

				let pages = getCurrentPages();
				if (pages.length >= 2) {

					uni.request({
						url: this.$api.baseUrl + '/api/user/money/receive',
						header: {
							'content-type': 'application/json'
						},
						data: {
							"user_id": uni.getStorageSync('roomchat_user_uid'),
							"transfer_id": this.receiver,

						},
						method: 'POST',
						success: res => {
							console.log(this.$api.baseUrl)
							console.log(res)
							uni.hideLoading()

						},
						fail: res => {
							console.log(res);
						}
					});



				}

			},



			handleDirlog(e, item) {
				console.log(e);
				console.log(item);
				e.item = item;
				e.my_user_id = this.fromUserId;
				e.is_roomchat = 1;
				this.wxPupData = e;
				console.log(this.wxPupData)
			},
			wxpupchange(item) {
				console.log(item)
				let message_item = this.wxPupData.item;
				console.log(message_item)


				let imgUrl = '';
				let s_type = '';
				switch (item.index) {
					case 1:
						uni.setClipboardData({
							data: message_item.dataContent
						});
						break
					case 2:
						let str = '[消息转发]' + '' + '和' + '' + '的聊天记录'
						message_item.str = str

						let list = [];
						list.push(message_item);
						// this.navTo('/pages/index/chosefriend?type=2&message_item=' + JSON.stringify(list))
						uni.navigateTo({
							url: '/pages/index/chosefriend?type=2',
							success: (res) => {
								res.eventChannel.emit('sharefriend', {
									'data': list
								});
							}
						});
						break
					case 3:
						if (message_item.contentType == 0) {
							message_item.quote_content = message_item.dataContent
						} else if (message_item.contentType == 1) {
							message_item.quote_content = '[图片]'
						} else if (message_item.contentType == 2) {
							message_item.quote_content = '[语音]'
						} else if (message_item.contentType == 3) {
							message_item.quote_content = '[赠送礼品]'
						} else if (message_item.contentType == 4) {
							message_item.quote_content = '[索取礼品]'
						} else if (message_item.contentType == 5) {
							message_item.quote_content = '[文件]'
						} else if (message_item.contentType == 6) {
							message_item.quote_content = '[短视频]'
						} else if (message_item.contentType == 7) {
							message_item.quote_content = '[名片]'
						} else if (message_item.contentType == 8) {
							message_item.quote_content = '[位置]'
						} else if (message_item.contentType == 11) {
							message_item.quote_content = '[笔记]'
						} else if (message_item.contentType == 10) {
							message_item.quote_content = '[红包]'
						} else if (message_item.contentType == 12) {
							message_item.quote_content = '[转账]'
						} else if (message_item.contentType == 16) {
							message_item.quote_content = '[圈子名片]'
						} else if (message_item.contentType == 31) {
							if (message.dataContent.type == 'video') {
								message_item.quote_content = '[视频通话]'
							} else {
								message_item.quote_content = '[语音通话]'
							}
						} else if (message_item.contentType == 90) {
							message_item.quote_content = str.m
						} else if (str.ty == 91) {
							message_item.quote_content = '消息撤回'
						}

						this.quoteinfo = message_item;
						console.log(this.quoteinfo);
						break
					case 4:

						this.deltype = true;
						this.update_item = message_item;
						// this.deletedata(message_item);
						break
					case 5:
						this.collectdata(message_item);
						break
					case 7:
						this.is_more = true;
						this.$forceUpdate();
						break
					case 8: ////撤回
						let msg = {};
						msg.fpForMessage = message_item.fp;
						msg.nickName = message_item.nickname;
						msg.uid = message_item.from1;
						console.log(msg);
						this.sendGroupMssage(JSON.stringify(msg), 91);
						break
					case 9:
						this.saveImage(message_item);
						break
					case 10:
						// this.saveImage(message_item);
						break
					case 11:
						imgUrl = 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message_item
							.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent
						this.downimg(imgUrl);
						break
					case 12:

						imgUrl = '';
						if (message_item.contentType == 1) {
							imgUrl =
								'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' + message_item
								.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent;
							s_type = 'image';

							uni.downloadFile({
								url: imgUrl, //图片地址
								success: res => {

									let content = res.tempFilePath;


									var msg = {
										pictures: [content], // 图片的本地路径
										success: function(res) {
											console.log('分享图片成功');
										},
										fail: function(err) {
											console.log('分享图片失败: ' + JSON.stringify(err));
										}
									};
									plus.share.sendWithSystem(msg);

								}
							});


						} else if (message_item.contentType == 6) {
							imgUrl =
								`http://chat.zwsmcn.com:8090/chatfile/shortvideo/normal/${message_item.dataContent.fileMd5}.mp4`
							s_type = 'video';
							let msg = {
								type: 'video',
								videoUrl: imgUrl
							};

							console.log(imgUrl);

							plus.share.sendWithSystem(msg, function() {
								console.log('分享成功');
							}, function(e) {
								console.log('分享失败:' + JSON.stringify(e));
							});
							return;
							uni.downloadFile({
								url: imgUrl, //图片地址
								success: res => {
									// let content = res.tempFilePath;
									// let filePath = content;
									console.log(res.tempFilePath);
									plus.io.resolveLocalFileSystemURL(res.tempFilePath, function(entry) {
										console.log(JSON.stringify(entry));
										console.log(entry.toLocalURL());
										// 文件存在，继续分享操作
										var msg = {
											// content: entry.toLocalURL(), // 获取文件本地URL路径
											type: 'video', // 分享类型为视频
											extra: {
												title: '分享视频', // 分享的标题
												content: '这是一个视频分享', // 分享的描述
												video: entry.toLocalURL() // 视频文件路径
											},

											success: function() {
												console.log("视频分享成功");
											},
											fail: function(e) {
												console.error("视频分享失败: " + JSON.stringify(e));
											}
										};
										// 发送分享请求
										plus.share.sendWithSystem(msg);
									}, function(e) {
										console.error("获取视频文件失败: " + JSON.stringify(e));
									});



								}
							});
						}


						break
					case 13:
						if (message_item.contentType == 1) {
							let imgUrl = 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' +
								message_item
								.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent
							let arr = [];
							arr.push(imgUrl)

							uni.previewImage({
								urls: arr,
							})
						} else if (message_item.contentType == 6) {
							let url =
								`http://chat.zwsmcn.com:8090/ShortVideoDownloader?user_uid=${message_item.from1}&file_name=${message_item.dataContent.fileMd5}&file_md5=${message_item.dataContent.fileMd5}.mp4`;
							// this.videourl = url;
							let url1 =
								`http://chat.zwsmcn.com:8090/chatfile/shortvideo/normal/${message_item.dataContent.fileMd5}.mp4`;
							this.videourl = url1;

							this.videoplay = true;
							this.BoFang();
						} else if (message_item.contentType == 8) {
							// //地图
						} else if (message_item.contentType == 11) {
							// //笔记
							this.Notesinfo = message_item.dataContent;
							this.NotesShow = true;
						}

						break

				}

				this.wxPupData = {};

			},


			downimg(imgUrl) {
				uni.showLoading({
					title: '正在下载...'
				});

				uni.downloadFile({
					url: imgUrl, //图片地址
					success: res => {
						// console.log(res);
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.hideLoading();
									uni.showToast({
										title: '保存成功',
										icon: 'none'
									});
								},
								fail: function(err) {
									// util.hideToast()
									if (
										err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" ||
										err.errMsg === "saveImageToPhotosAlbum:fail auth deny" ||
										err.errMsg ===
										"saveImageToPhotosAlbum:fail authorize no response"
									) {
										wx.showModal({
											title: '提示',
											content: '需要您授权保存相册',
											showCancel: false,
											success: res => {
												wx.openSetting({
													success(settingdata) {
														console.log("success",
															settingdata)
														if (settingdata
															.authSetting[
																'scope.writePhotosAlbum'
															]) {
															uni.hideLoading();
															wx.showModal({
																title: '提示',
																content: '获取权限成功,再次点击下载即可保存',
																showCancel: false,
															})
														} else {
															uni.hideLoading();
															wx.showModal({
																title: '提示',
																content: '获取权限失败，将无法保存到相册哦~',
																showCancel: false,
															})
														}
													},
													fail(err) {
														uni.hideLoading();
														console.log("fail",
															err)
													},
													complete(res) {
														console.log("finish",
															res)
													}
												})
											}
										})
									} else if (err.errMsg ===
										"saveImageToPhotosAlbum:fail cancel") {
										uni.hideLoading();
										wx.showModal({
											title: '提示',
											content: '取消了保存图片,再次点击下载即可保存',
											showCancel: false,
										})
									} else {
										uni.hideLoading();
										wx.showModal({
											title: '提示',
											content: err.errMsg,
											showCancel: false,
										})
									}
								}
							});
						}
					}
				});
			},
			deletedata(message_item) {
				const currentTime = new Date();
				const target = new Date(message_item.time);
				const difference = currentTime - target;
				const seconds = Math.abs(difference / 1000);
				const minutes = seconds / 60;

				if (minutes <= 5) {
					let msg = {};
					msg.fpForMessage = message_item.fp;


					msg.nickName = message_item.nickname;
					msg.uid = message_item.from1;
					console.log(msg);
					if (this.isGroup == 1 && this.groupinfo.isRetractedMsg == 0) {

					} else {
						this.sendGroupMssage(JSON.stringify(msg), 91);
					}
				}


				let index = this.listData.findIndex(item => item.fp == message_item.fp)
				if (index >= 0) {
					this.listData.splice(index, 1)
				}
				this.$forceUpdate();

				let data = `del_flag = 1`;
				let where = `(fp = '${message_item.fp}')`
				// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
				DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
					.then(res => {
						console.log(res);
						this.deltype = false
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			saveImage(message_item) {

				console.log(message_item);

				uni.request({
					url: this.$api.baseUrl + '/api/common/image/add',
					header: {
						'content-type': 'application/json'
					},
					data: {
						user_id: uni.getStorageSync('roomchat_user_uid'),
						image: 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' +
							message_item
							.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent,
						image_name: message_item.dataContent
					},
					method: 'POST',
					success: res => {
						console.log(this.$api.baseUrl + '/api/common/image/add');
						console.log(uni.getStorageSync('roomchat_user_uid'));
						console.log('http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' +
							message_item.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent);
						console.log(res);
						// uni.hideLoading()
						if (res.data.code == 0) {
							this.getImage();
						}
						console.log(this.list);
						// this.list = res.data;
					},
					fail: res => {
						console.log(res);
					}

				})
			},

			getImage() {


				uni.request({
					url: this.$api.baseUrl + '/api/common/image/fetch',
					header: {
						'content-type': 'application/json'
					},
					data: {
						user_id: Number(uni.getStorageSync('roomchat_user_uid')),
					},
					method: 'POST',
					success: res => {
						// uni.hideLoading()
						if (res.data.code == 0) {
							this.imageList = res.data.data;
						}
					},
					fail: res => {
						console.log(res);
					}

				})
			},
			collectdata(message_item) {

				console.log(message_item.is_collect);

				let is_collect = 1;
				let data = '';
				if (Number(message_item.is_collect) === 1) {
					console.log(11);
					data = `is_collect = 0`;
					is_collect = 0;
				} else {
					data = `is_collect = 1`;
					is_collect = 1;
				}
				let where = `fp = '${message_item.fp}'`
				// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
				DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
					.then(res => {
						let index = this.listData.findIndex(item => item.fp == message_item.fp)
						if (index >= 0) {

							console.log(is_collect);
							this.listData[index].is_collect = is_collect;
						}
						this.$forceUpdate();
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			// //举报
			addwarn(message_item) {

				console.log(message_item);

				uni.request({
					url: this.$api.baseUrl + '/api/common/warn/add',
					header: {
						'content-type': 'application/json'
					},
					data: {
						type: 4,
						warn_type: '', ////违规类型：关联api_warn_type表
						user_id: uni.getStorageSync('roomchat_user_uid'),
						content: message_item.dataContent,
						pictures: 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' +
							message_item.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent,
						warn_type_id: message_item.from1
					},
					method: 'POST',
					success: res => {
						console.log(this.$api.baseUrl + '/api/common/image/add');
						console.log(uni.getStorageSync('roomchat_user_uid'));
						console.log('http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' +
							message_item.from1 + '&need_dump=0&file_name=th_' + message_item.dataContent);
						console.log(res);
						// uni.hideLoading()
						if (res.data.code == 0) {
							this.getImage();
						}
						console.log(this.list);
						// this.list = res.data;
					},
					fail: res => {
						console.log(res);
					}

				})
			},
			checkboxChange(e) {

				this.checkedArray = e.detail.value;

				this.more_list = [];
				this.checkedArray.forEach(newCheckedItem => {
					this.more_list.push("'" + newCheckedItem.fp + "'");

				});


				let f_list = this.checkedArray.filter(item => item.contentType == 1 || item.contentType == 6);
				if (f_list.length > 0) {
					this.is_more_image = true;
				} else {
					this.is_more_image = false;
				}
			},

			updateAllData(type) {

				if (this.more_list.length == 0) {
					return
				}
				if (type == 2) {
					let list = [];
					for (let ii = 0; ii < this.checkedArray.length; ii++) {
						let message_item = this.checkedArray[ii];
						let str = '[消息转发]' + '' + '和' + '' + '的聊天记录'
						message_item.str = str
						list.push(message_item);
					}
					// this.navTo('/pages/index/chosefriend?type=2&message_item=' + JSON.stringify(list))
					console.log(list);
					uni.navigateTo({
						url: '/pages/index/chosefriend?type=2',
						success: (res) => {
							console.log(res);
							res.eventChannel.emit('sharefriend', {
								'data': list
							});
						}
					});

					return;
				}
				if (type == 3) {
					uni.showModal({
						title: '提示',
						content: '可保存的消息类型为:图片、视频以及笔记，其它类型的消息无法保存',
						cancelText: '取消',
						confirmText: '确定',
						cancelColor: '#000',
						confirmColor: '#40AFFE',
						success: res => {
							if (res.confirm) {
								for (let ii = 0; ii < this.checkedArray.length; ii++) {
									if (this.checkedArray[ii].contentType == 1 || this.checkedArray[ii]
										.contentType == 6) {
										let imgUrl = '';
										let item = this.checkedArray[ii];
										if (item.contentType == 1) {
											imgUrl =
												'http://chat.zwsmcn.com:8090/BinaryDownloader?action=image_d&user_uid=' +
												item
												.from1 + '&need_dump=0&file_name=th_' + item.dataContent
										} else if (item.contentType == 6) {
											imgUrl =
												`http://chat.zwsmcn.com:8090/chatfile/shortvideo/normal/${item.dataContent.fileMd5}.mp4`
										}

										this.downimg(imgUrl);
									}
								}

								this.is_more = false;
								this.is_more_image = false;
								this.more_list = [];
								this.checkedArray = [];
							} else if (res.cancel) {
								this.is_more = false;
								this.is_more_image = false;
								this.more_list = [];
								this.checkedArray = [];
							}
						}
					});


					return;
				}

				const fpList = this.more_list.join(',');

				// let index = this.listData.findIndex(item => item.fp == message_item.fp)
				// if (index >= 0) {
				// 	this.listData.splice(index, 1)
				// }
				// this.$forceUpdate();
				let data = '';
				let where = '';
				let key = '';

				if (type == 1) {
					data = `is_collect = 1`;
					where = `fp IN  (${fpList})`
				}
				if (type == 4) {
					data = `del_flag = 1`;
					where = `fp IN  (${fpList})`
				}

				// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
				DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
					.then(res => {
						console.log(res);
						this.is_more = false;
						this.is_more_image = false;
						this.more_list = [];
						this.checkedArray = [];

						this.selectTableData();

					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			reback() {
				this.videoplay = false;
				this.videourl = '';
				this.exit();
			},
			continuePlay(e) {
				console.log(e);
				console.log('continuePlay');
			},

			showvideo(item) {
				console.log(item);

				let url =
					`http://chat.zwsmcn.com:8090/ShortVideoDownloader?user_uid=${item.from1}&file_name=${item.dataContent.fileMd5}&file_md5=${item.dataContent.fileMd5}.mp4`;
				// this.videourl = url;
				let url1 =
					`http://chat.zwsmcn.com:8090/chatfile/shortvideo/normal/${item.dataContent.fileMd5}.mp4`;
				this.videourl = url1;
				console.log(url1);
				console.log(this.videourl);
				this.videoplay = true;
				this.BoFang();
				// if (this.videoContext) {
				//     this.videoContext.play();
				//   }
			},
			// 视频播放
			BoFang() {
				if (this.autoplay == false) {
					// this.playmusic();
					this.autoplay = true;
					this.videoContext.play();
					console.log(this.autoplay);
				}
			},
			ZhanTing() {
				if (this.autoplay == true) {
					// this.playmusic();
					this.videoContext.pause();
					this.autoplay = false;
				}
			},
			exit() {
				// this.playmusic();
				this.videoContext.pause();
				this.autoplay = false;
			},
			resetmore() {
				this.is_more = false;
				this.is_more_image = false;
				this.more_list = [];
				this.checkedArray = [];

			},

			getredinfo(item) {
				this.sendGroupMssage(item, 10);
			},
			gettransferinfo(item) {
				// 转账
				this.sendGroupMssage(item, 12);
			},
			getnotesinfo(item) {
				// //笔记
				this.sendGroupMssage(item, 11);
			},
			getcollect(list) {
				console.log(list);
				for (let i = 0; i < list.length; i++) {
					this.sendGroupMssage(list[i].dataContent, list[i].contentType);
				}
				// this.sendGroupMssage(item, 11);
			},
			// 名片消息
			getcontactinfo(item) {

				this.sendGroupMssage(item, 7);
			},
			scrollToBottom() {
				let that = this;
				// 滚动到底部
				// 注意：使用$nextTick方法是为了等待页面渲染完成后再设置scrollTop，否则有新消息显示这种情
				//      况时只能滚动到倒数第2条的问题，参考资料：https://www.52code.net/a/bPDJwPXyBY
				this.$nextTick(() => {
					// 设置聊天列表的scroll-view垂直滚动条位置来实现自动滚到
					// 消息列表底部(+1是因为scrollview列表硬编码了一条预定义的系统消息)
					that.scrollPageTop = (that.listData.length + 1) * 999;
				});
			},

			/**
			 * 注册im相关的应用层事件。
			 */
			registerIMEvents() {
				let that = this;

				// 提示：ES6的箭头函数中this指向的是外部调用者，而function()这种匿名函数则是指向它自身，别理解错

				// 注册应用层事件通知：事件发生于收到聊天消息时，此处接收通知并在UI上展现出来
				EventBus.register(EventType.onIMData, (p, options) => {
					// console.log(p)
					let p_dataContent = JSON.parse(p.dataContent);

					if ((p.typeu == 3 && (
							(p.from == this.fromUserId && p.to == this.info.user_uid) ||
							(p.from == this.info.user_uid && p.to == this.fromUserId))) ||
						(p.typeu == 45 && p_dataContent.t == this.info.g_id) ||
						(p.typeu == 43 && p_dataContent.t == this.fromUserId && p_dataContent
							.f == this.info.user_uid)) {

						let update_data = JSON.parse(p.dataContent);
						let dataContent = JSON.parse(p.dataContent);
						// console.log(dataContent);
						if (dataContent.ty == 30) {
							console.log(dataContent);
							console.log(dataContent.f);
							console.log(Date.now());
							console.log('dataContent');
							// this.getmessage(dataContent.f,dataContent.t);
						}
						if (dataContent.ty == 91) {

							update_data.m = '消息撤回';
							let update_data_str = JSON.stringify(update_data);
							p.dataContent = update_data_str;
							if (dataContent.m.indexOf('fpForMessage') >= 0) {
								let m = JSON.parse(dataContent.m)
								console.log(m.fpForMessage);
								let data = `dataContent = '${update_data_str}'`;

								let where = `fp = '${m.fpForMessage}'`
								// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
								DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
									.then(res => {
										console.log(res);

										p.time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
										console.log(this.listData);
										console.log(m
											.fpForMessage);
										let f_index = this.listData.findIndex(item => item.fp == m
											.fpForMessage)
										console.log(f_index);

										if (f_index >= 0) {
											let chatMsg = this.constructMessage(p);
											this.listData[f_index] = chatMsg;
										}

										this.selectTableData();
										// 添加聊天消息到ui消息列表中

									})
									.catch(error => {
										console.log("修改失败", error);
									});
							} else {
								// p.time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
								// // 添加聊天消息到ui消息列表中
								// let chatMsg = that.constructMessage(p);
								// that.listData.push(chatMsg);
								// 自动滚动到列表底部

							}



							that.scrollToBottom();
							that.$forceUpdate();
						} else if (dataContent.ty == 13 || dataContent.ty == 14) {
							let m_z = JSON.parse(dataContent.m);
							m_z.receivetime = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
							m_z.is_receive = 1;
							if (dataContent.ty == 13) {
								update_data.ty = 10;
							} else {
								update_data.ty = 12;
							}

							let where = `(fp = '${m_z.fp}')`
							update_data.m = JSON.stringify(m_z);
							let update_data_str = JSON.stringify(update_data);
							let data = `dataContent = '${update_data_str}'`;
							DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
								.then(res => {

								})
								.catch(error => {
									console.log("修改失败", error);
								});
						} else if (dataContent.ty == 20) {
							let m_z = dataContent.m; //JSON.parse(dataContent.m);
							console.log(m_z)
							let where = `(fp = '${m_z.fp}')`

							let data = `is_read = 1`;
							DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
								.then(res => {

								})
								.catch(error => {
									console.log("修改失败", error);
								});
						} else {
							// uni.vibrateShort({
							// 	success: () => {
							// 		console.log('短时间震动完成');
							// 	}
							// });
							// if (uni.getStorageSync('mp3') == 0) {
							// 	this.playRingtone()
							// }

							let send_message = {};
							send_message.fp = p.fp;
							that.sendGroupMssage(send_message, 20);


							p.time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
							let m_z = dataContent.m; //JSON.parse(dataContent.m);
							let where = `(fp = '${p.fp}')`

							// let data = `is_read = 1`;
							// DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
							// 	.then(res => {

							// 	})
							// 	.catch(error => {
							// 		console.log("修改失败", error);
							// 	});

							// 添加聊天消息到ui消息列表中
							let chatMsg = that.constructMessage(p);
							that.listData.push(chatMsg);
							// 自动滚动到列表底部
							that.scrollToBottom();
						}


					} else if ((p.typeu == 46 || p.typeu == 47 || p
							.typeu == 49 || p.typeu == 50 || p.typeu == 51) && p_dataContent.t == this.info.g_id) {
						console.log(p.typeu);
						setTimeout(() => {
							this.selectTableData();
						}, 500)
					} else if (p.typeu == 48 && p_dataContent.t == this.info.g_id) {
						this.getDetail();
					}
				});

				// 注册应用层事件通知：事件发生于客户端成功登陆/认证后，此处接收通知并在UI上展开相关逻辑
				EventBus.register(EventType.onIMAfterLoginSucess, () => {
					// 设置已成功登录标识并通知ui刷新
					that.loginSucess = true;
					// 刷新网络连接情况的ui显示
					// that.refreshConnectionStatus();
				});

				// 注册应用层事件通知：事件发生于客户端登陆/认证失败后（可能是被禁、token/密码被重置等，具体由服务端决定）
				EventBus.register(EventType.onIMAfterLoginFailed, (isReconnect) => {
					imManager.log('对不起，你' + (isReconnect ? '自动重连' : '登陆') + 'IM服务器失败了 ...', false);
				});

				// 注册应用层事件通知：事件发生于客户端与服务器的网络断开后
				EventBus.register(EventType.onIMDisconnected, () => {
					imManager.log('Sorry，你掉线了 ...', false);
					uni.IMSDK.loginImpl(uni.getStorageSync('loginInfo'), uni.MBCore
						.getWebsocketUrl(), false);
					// 刷新网络连接情况的ui显示
					// that.refreshConnectionStatus();
				});

				// 注册应用层事件通知：事件发生于客户端掉线重连成功后
				EventBus.register(EventType.onIMReconnectSucess, () => {
					imManager.log('掉线自动重连成功了!', false);
					// 刷新网络连接情况的ui显示
					// that.refreshConnectionStatus();
				});

				// 注册应用层事件通知：事件发生于客户端收到服务端的心跳响应包，此事件对于应用层无实质性意义，一般无需理会
				EventBus.register(EventType.onIMPong, () => {
					// 绿色呼吸灯效果（表示心跳在后面正常工作中...）
					// that.setConnectionStatusIconLight(true);
					// setTimeout(function() {
					// 	that.setConnectionStatusIconLight(false);
					// }, 500);
				});

				// 注册应用层事件通知：事件发生于聊天消息/指令未成功送达时，此处接收通知可在UI界面上标记未送出的消息
				EventBus.register(EventType.onMessagesLost, (lostMessages) => {
					imManager.log("[DEMO-UI] [消息未成功送达]共" + lostMessages.length + "条!(网络状况不佳或对方id不存在)", true);
					// // 更新ui显示（显示一个未送红色小图标）
					// that.updateMessagesSendStatus(lostMessages, -1);
				});

				// 注册应用层事件通知：事件发生于聊天消息/指令已被对方收到，此处接收通知可在UI界面上标记已送达的消息
				EventBus.register(EventType.onMessagesBeReceived, (theFingerPrint) => {
					imManager.log("[DEMO-UI] [收到消息应答]fp=" + theFingerPrint, true);
					// 更新ui显示
					// that.updateMessageSendStatus(theFingerPrint, 1);
				});
			},

			constructMessage(p) {

				let nicknamehashMap = uni.getStorageSync('nicknamehashMap');
				let avatarhashMap = uni.getStorageSync('avatarhashMap');

				let nickname = '';
				let avatar = '';
				if (nicknamehashMap) {
					nicknamehashMap = new Map(JSON.parse(nicknamehashMap));

					nickname = nicknamehashMap.get(p.from) ?? '';
				}
				if (avatarhashMap) {
					avatarhashMap = new Map(JSON.parse(avatarhashMap));

					avatar = avatarhashMap.get(p.from) ?? '';
				}

				let chatMsg = {};
				let dataContent = JSON.parse(p.dataContent);

				chatMsg.from1 = dataContent.f
				chatMsg.to1 = dataContent.t

				chatMsg.dataContent = dataContent.m
				chatMsg.quote_fp = dataContent.quote_fp ?? ''
				chatMsg.quote_sender_uid = dataContent.quote_sender_uid ?? ''
				chatMsg.quote_sender_nick = dataContent.quote_sender_nick ?? ''
				chatMsg.quote_status = dataContent.quote_status ?? ''
				chatMsg.quote_content = dataContent.quote_content ?? ''
				chatMsg.quote_type = dataContent.quote_type ?? ''



				if (dataContent.ty == 7 || dataContent.ty == 10 || dataContent.ty == 11 || dataContent.ty == 12) {
					chatMsg.dataContent = JSON.parse(dataContent.m)
				}

				if (dataContent.ty == 6) {

					chatMsg.dataContent = JSON.parse(dataContent.m)

				}
				if (dataContent.ty == 8) {

					chatMsg.dataContent = JSON.parse(dataContent.m)

				}
				if (dataContent.ty == 5) {

					chatMsg.dataContent = JSON.parse(dataContent.m)

				}
				if (dataContent.ty == 16) {

					chatMsg.dataContent = JSON.parse(dataContent.m)

				}
				if (dataContent.ty == 31) {

					chatMsg.dataContent = JSON.parse(dataContent.m)

				}

				chatMsg.time = p.time; // uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
				chatMsg.contentType = dataContent.ty
				chatMsg.fp = p.fp;

				if (dataContent.parentFp) {
					chatMsg.fp = dataContent.parentFp;
				}



				chatMsg.is_collect = 0;
				chatMsg.is_read = p.is_read;
				if (p.is_collect) {
					chatMsg.is_collect = p.is_collect;
				}
				if (p.typeu == 44 || p.typeu == 45) {
					chatMsg.nickname = dataContent.nickName
				} else if (p.typeu == 46) {
					chatMsg.from1 = p.from1
					chatMsg.to1 = p.gid
					chatMsg.contentType = p.chat_type
					chatMsg.dataContent = '“' + dataContent.initveBeNickName + '”邀请你加入群聊' + dataContent.g_name
				} else if (p.typeu == 50 || p.typeu == 49) {

					chatMsg.dataContent = dataContent.m
				} else if (p.typeu == 51) {
					chatMsg.from1 = p.from1
					chatMsg.to1 = p.gid
					chatMsg.contentType = p.chat_type
					chatMsg.dataContent = dataContent.notificationContent
				} else if (p.typeu == 3) {
					if (dataContent.f == this.fromUserId) {
						chatMsg.nickname = uni.getStorageSync('roomchat_nickname') ?? ''
					} else {
						chatMsg.nickname = nickname
					}

				} else if (p.typeu == 10) {
					// chatMsg.dataContent = dataContent
					chatMsg.contentType = 90;
					chatMsg.dataContent = '你们已经是好友了，现在可以好友模式聊天了。';
				}

				if (!dataContent.nickName) {
					chatMsg.nickname = '';
				} else {
					chatMsg.nickname = dataContent.nickName;
				}

				if (!dataContent.userAvatar) {
					chatMsg.userAvatar = '';
				} else {
					chatMsg.userAvatar =
						`http://chat.zwsmcn.com:8090/UserAvatarDownloader?action=ad&user_uid=${chatMsg.from1}&user_local_cached_avatar=${dataContent.userAvatar}&enforceDawnload=1&token=`;
				}


				if (dataContent.ty == 2) {
					chatMsg.contentDuration = dataContent.contentDuration;
					chatMsg.anmitionPlay = false;

				}
				// if (p.chat_type == 90) {
				// 	chatMsg.dataContent = dataContent

				// }
				chatMsg.typeu = p.typeu

				chatMsg.multiSelect = false;

				// console.log(chatMsg);
				// console.log('constructMessage');
				return chatMsg;


			},

			openSQL() {
				// 这个是查询有没有打开数据库
				let open = DB.isOpen();
				console.log("数据库状态", open ? "开启" : "关闭");
				if (!open) {
					DB.openSqlite()
						.then(res => {
							console.log("数据库已打开");
						})
						.catch(error => {
							console.log("数据库开启失败");
						});
				}
			},

			// 关闭数据库
			closeSQL() {
				// 这个是查询有没有打开数据库
				let open = DB.isOpen();
				if (open) {
					DB.closeSqlite()
						.then(res => {
							console.log("数据库已关闭");
						})
						.catch(error => {
							console.log("数据库关闭失败");
						});
				}
			},

			// 创建表
			createTable() {
				let open = DB.isOpen();
				if (open) {
					// this.openSQL();
					// 修改后的表结构定义语句，列名不用双引号括起来
					let sql =
						'id INTEGER PRIMARY KEY AUTOINCREMENT, type text, dataContent text, from1 text, to1 text, QoS text, typeu text, sm text, fp text, retryCount text DEFAULT 0, time text,nickname text,avatar text,is_read text DEFAULT 0,gid text,is_collect text DEFAULT 0,del_flag text DEFAULT 0,chat_type text,relatedId text,is_top INTEGER DEFAULT 0,is_mute INTEGER DEFAULT 0';
					// 创建表 DB.createTable(表名, 表的列)
					DB.createTable("chat" + uni.getStorageSync("roomchat_user_uid"), sql)
						.then(res => {
							console.log("创建chat表成功", res);
						})
						.catch(error => {
							console.log("创建表失败", error);
						});
				} else {
					console.log("数据库未打开");
				}
			},
			// 新增表数据
			insertTableData(p) {
				// console.log(p)
				let open = DB.isOpen();
				if (open) {
					let arr = []
					arr.push(p)
					// 如果需要根据p参数插入新数据，可以在这里正确处理p与arr的关系，例如arr.push(p)等操作

					arr.map(item => {
						// console.log(item, 'arr-=-=-=-=-=arr-=-=-=-')
						let dataContent = JSON.parse(item.dataContent);
						let chat_type = dataContent.ty

						let time = this.formatDate(new Date().getTime());
						let sm = 0;
						if (item.sm) {
							sm = item.sm;
						}
						let is_read = p.is_read ?? 0;

						if (item.from == this.fromUserId) {
							is_read = 1;
						}

						let relatedId = '';
						if (!item.gid || item.gid == '0') {
							if (item.from == uni.getStorageSync('roomchat_user_uid')) {
								relatedId = item.to;
							} else {
								relatedId = item.from;
							}
						} else {
							relatedId = item.gid;
						}
						let disturbhashMap = uni.getStorageSync('disturbhashMap' + uni.getStorageSync(
							"roomchat_user_uid"));
						let tophashMap = uni.getStorageSync('tophashMap' + uni.getStorageSync(
							"roomchat_user_uid"));

						let is_top = 0;
						let is_mute = 0;
						if (disturbhashMap) {
							disturbhashMap = new Map(JSON.parse(disturbhashMap));
							is_mute = disturbhashMap.get(relatedId) ?? false;
							is_mute = Number(is_mute) ?? 0;
						}
						if (tophashMap) {
							tophashMap = new Map(JSON.parse(tophashMap));

							is_top = tophashMap.get(relatedId) ?? false;
							is_top = Number(is_top) ?? 0;
						}

						let from = item.from;
						let to = item.to;
						if (item.typeu == 42) {
							from = dataContent.f;
							to = dataContent.t;
						}
						let sql =
							`'${item.type}', '${item.dataContent}', '${from}', '${to}', '${item.QoS}', '${item.typeu}', '${sm}', '${item.fp}', '${item.retryCount}', '${time}', '${item.gid}',0,0, '${chat_type}',${is_read},'${relatedId}',${is_top},${is_mute}`;
						console.log(sql, "-=-=-=-=-=sas")
						// this.info
						let condition =
							'type, dataContent, from1, to1, QoS, typeu, sm, fp, retryCount, time, gid,is_collect,del_flag,chat_type,is_read,relatedId,is_top,is_mute';
						// 新增 DB.insertTableData(表名, 对应表头列的数据)

						// console.log('insertTableData4')
						DB.insertTableData("chat" + uni.getStorageSync("roomchat_user_uid"), sql, condition)
							.then(res => {
								console.log("新增数据成功");
								// this.selectTableData();
							})
							.catch(error => {
								console.log("失败", error);
							});
					})


				} else {
					this.$util.toast("数据库未打开");
				}
			},
			// 查询表数据
			selectTableData() {
				let open = DB.isOpen();
				if (open) {
					// 查询表 DB.selectTableData(表名,查询条件列名,查询条件列值)
					if (this.isGroup == 1) {
						DB.selectGroupmessage("chat" + uni.getStorageSync("roomchat_user_uid"), "gid", this.info.g_id)
							.then(res => {
								console.log("contact表数据-=-=-=-==-==-", res);



								this.listData = [];
								res.map(item => {
									// console.log(item)
									let chatMsg = this.constructMessage(item);


									this.listData.push(chatMsg);

								})
								this.$forceUpdate();
								console.log(this.listData)
								setTimeout(() => {
									// this.$refs.scrollView.scrollToBottom(); // 滚动到底部
									this.scrollToBottom();

								}, 500)
							})
							.catch(error => {
								console.log("查询失败", error);
								// this.createTable();
								if (error.code == '-1404') {
									this.createTable();
								}

							});
					} else {
						DB.selectTableData("chat" + uni.getStorageSync("roomchat_user_uid"), "from1", uni.getStorageSync(
								'roomchat_user_uid'), "to1", this.info.user_uid)
							.then(res => {
								console.log("contact表数据-=-=-=-==-==-", res);


								this.listData = [];
								res.map(item => {
									let chatMsg = this.constructMessage(item);


									this.listData.push(chatMsg);

								})
								this.$forceUpdate();
								console.log(this.listData)
								setTimeout(() => {
									// this.$refs.scrollView.scrollToBottom(); // 滚动到底部
									this.scrollToBottom();

								}, 500)
								// this.listData = res;
							})
							.catch(error => {
								console.log("查询失败", error);
								// this.createTable();
								if (error.code == '-1404') {
									this.createTable();
								}

							});
					}


				} else {
					this.$util.toast("数据库未打开");
				}
			},


			// 修改表数据
			updateTableData() {
				let open = DB.isOpen();
				if (open) {
					let time = this.formatDate(new Date().getTime());
					// let data = `content = '我被修改了',time = '${time}'`;
					let data = `is_read = 1`;
					let where = '';
					if (this.isGroup == 0) {
						where =
							`(from1 = '${uni.getStorageSync('roomchat_user_uid')}' AND to1 = '${this.info.user_uid}') or (from1 = '${this.info.user_uid}' AND to1 = '${uni.getStorageSync('roomchat_user_uid')}')`

					} else {
						where =
							`(gid = '${this.info.g_id}')`

					}
					// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
					DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
						.then(res => {
							this.selectTableData();
						})
						.catch(error => {
							console.log("修改失败", error);
						});

					return;
					// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
					DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, "from1", uni.getStorageSync(
							'roomchat_user_uid'), "to1", this.info.user_uid)
						.then(res => {
							// this.$util.toast("更新chat表成功");
							this.selectTableData();
						})
						.catch(error => {
							console.log("修改失败", error);
						});
				} else {
					this.$util.toast("数据库未打开");
				}
			},

			// 删除表数据
			deleteTableData() {
				let open = DB.isOpen();
				if (open) {
					// 删除表 DB.deleteTableData(表名,查询条件列名,查询条件列值)
					DB.deleteTableData("chat" + uni.getStorageSync("roomchat_user_uid"), "name", "小红")
						.then(res => {
							this.$util.toast("删除表数据成功");
							this.selectTableData();
						})
						.catch(error => {
							console.log("删除失败", error);
						});
				} else {
					this.$util.toast("数据库未打开");
				}
			},
			// 提示框
			showToast: function(str) {
				uni.showToast({
					icon: "none",
					title: str,
					mask: true
				});
			},
			// 时间戳转年月日
			formatDate(data) {
				let now = new Date(data);
				var year = now.getFullYear(); //取得4位数的年份
				var month =
					now.getMonth() + 1 < 10 ?
					"0" + (now.getMonth() + 1) :
					now.getMonth() + 1;
				var date = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
				var hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
				var minute =
					now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
				var second =
					now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
				return (
					year +
					"-" +
					month +
					"-" +
					date +
					" " +
					hour +
					":" +
					minute +
					":" +
					second
				);
			},

			goqun(item) {
				this.toPage('/pages/contacts/groupManagement?groupId=' + JSON.stringify(item));
			},
			person() {
				this.dirlogShow = true
			},
			toinformation(user_uid) {


				if (this.isGroup == 1 && this.groupinfo.isSeeMember == 0 && this.groupinfo.g_owner_user_uid != this
					.fromUserId) {

				} else {
					this.toPage('/pages/contacts/information?isGroup=' + this.isGroup + '&user_uid=' + user_uid);
				}

			},
			goNavigation(item) {
				console.log(item);
				uni.openLocation({
					type: 'wgs84',
					latitude: item.dataContent.latitude,
					longitude: item.dataContent.latitude,
					name: item.dataContent.name,
					address: item.dataContent.address,
					success: res => {
						console.log('success');
					}
				});
			},
			receiveRed(item) {
				console.log(item);
				if (this.isGroup == 0) {
					if (item.from1 == this.fromUserId) {
						if (this.isGroup == 0) {
							if (item.to1 == uni.getStorageSync('roomchat_user_uid')) {
								item.receive_name = uni.getStorageSync('roomchat_nickname') ?? '';
								item.receive_avatar = uni.getStorageSync('roomchat_user_avatar_file_name') ?? '';
							} else {
								item.receive_name = this.info.nickname
								item.receive_avatar = this.info.avatar
							}
						} else {
							let index = -1;
							if (item.dataContent.isexclusive == 1) {
								this.originalArray.findIndex(item => item.user_uid == item.dataContent.exclusive_uid)
							}
							if (index >= 0) {
								item.receive_name = this.originalArray[index].nickname
								item.receive_avatar = this.originalArray[index].avatar
							} else {
								item.receive_name = ''
								item.receive_avatar = ''
							}

						}

						uni.navigateTo({
							url: '/pages/index/redreceiveInfo?item=' + JSON.stringify(item) + '&isGroup=' + this
								.isGroup,
							animationType: 'fade-in',
							animationDuration: 1,
						})
						return;
					}

				}
				if (item.dataContent.is_receive == 1) {
					if (this.isGroup == 0) {
						if (item.to1 == uni.getStorageSync('roomchat_user_uid')) {
							item.receive_name = uni.getStorageSync('roomchat_nickname') ?? '';
							item.receive_avatar = uni.getStorageSync('roomchat_user_avatar_file_name') ?? '';
						} else {
							item.receive_name = this.info.nickname
							item.receive_avatar = this.info.avatar
						}
					} else {
						let index = -1;
						if (item.dataContent.isexclusive == 1) {
							this.originalArray.findIndex(item => item.user_uid == item.dataContent.exclusive_uid)
						}
						if (index >= 0) {
							item.receive_name = this.originalArray[index].nickname
							item.receive_avatar = this.originalArray[index].avatar
						} else {
							item.receive_name = ''
							item.receive_avatar = ''
						}

					}

					uni.navigateTo({
						url: '/pages/index/redreceiveInfo?item=' + JSON.stringify(item) + '&isGroup=' + this
							.isGroup,
						animationType: 'fade-in',
						animationDuration: 1,
					})
					return;
				}


				if (this.isGroup == 1 && item.dataContent.isexclusive == 1 && item.dataContent.exclusive_uid != this
					.fromUserId) {
					this.$util.toast('该红包是专属红包，您不能领取')
					return;
				}

				this.reditem = item;
				this.isred = true;
			},
			receivetransfer(item) {
				console.log(item);
				if (item.from1 == this.fromUserId) {
					return;
				}
				if (item.dataContent.is_receive == 1) {
					// if(this.isGroup == 0){
					// 	if(this.reditem.to1 == uni.getStorageSync('roomchat_user_uid')){
					// 		this.reditem.receive_name = uni.getStorageSync('roomchat_nickname') ??'';
					// 		this.reditem.receive_avatar =  uni.getStorageSync('roomchat_user_avatar_file_name') ?? '';
					// 	}else{
					// 		this.reditem.receive_name = this.info.nickname
					// 		this.reditem.receive_avatar = this.info.avatar
					// 	}
					// }else{
					// 	let index = this.originalArray.findIndex(item=>item.user_uid == this.reditem.dataContent.exclusive_uid)
					// 	if(index >= 0){
					// 		this.reditem.receive_name = this.originalArray[index].nickname
					// 		this.reditem.receive_avatar = this.originalArray[index].avatar
					// 	}else{
					// 		this.reditem.receive_name = ''
					// 		this.reditem.receive_avatar = ''
					// 	}

					// }

					uni.navigateTo({
						url: '/pages/index/redreceiveInfo?item=' + JSON.stringify(item) + '&isGroup=' + this
							.isGroup,
						animationType: 'fade-in',
						animationDuration: 1,
					})
					return;
				}
				this.reditem = item;
				this.isred = true;
			},
			openPacker() {
				if (this.isGroup == 0) {
					this.updatered();
				} else {
					console.log(this.reditem.dataContent.isexclusive);
					if (this.reditem.dataContent.isexclusive == 0) {
						this.updategroupred();
					} else {
						this.updatered();
					}
				}

				// // 加载数据，触发硬币旋转动画
				// this.packerState = 1;
				// this.request(() => {
				// 	// 调用抢红包接口成功，触发开红包动画
				// 	this.packerState = 2;
				// 	// 开红包动画结束后，移除相关节点，否则会阻挡其它下层节点
				// 	setTimeout(() => {





				// 	}, 500);
				// })

			},
			updatered() {
				uni.request({
					url: this.$api.baseUrl + '/api/user/money/receive',
					header: {
						'content-type': 'application/json'
					},
					data: {
						"transfer_id": this.reditem.dataContent.transferId,

					},
					method: 'POST',
					success: res => {
						console.log(this.$api.baseUrl)
						console.log(this.reditem.dataContent.transferId)
						console.log(res)
						uni.hideLoading()
						if (res.data.code == 0) {
							// 加载数据，触发硬币旋转动画
							this.packerState = 1;
							this.request(() => {
								// 调用抢红包接口成功，触发开红包动画
								this.packerState = 2;
								// 开红包动画结束后，移除相关节点，否则会阻挡其它下层节点
								setTimeout(() => {


									let m_z = this.reditem.dataContent;
									m_z.is_receive = 1;
									m_z.title = this.reditem.dataContent.title;
									m_z.price = this.reditem.dataContent.price;
									m_z.sendtime = this.reditem.dataContent.sendtime;
									m_z.receivetime = uni.MBUtils.formatDate(new Date(),
										'yyyy-MM-dd hh:mm:ss');
									m_z.transferId = this.reditem.dataContent.transferId;
									if (this.isGroup == 1) {
										m_z.isexclusive = this.reditem.dataContent.isexclusive;
										m_z.exclusive_uid = this.reditem.dataContent
											.exclusive_uid ?? '';
									}

									let typeu = 44;
									let at = [];
									if (this.isGroup == 0) {
										typeu = 3;
									}
									let contentDuration = 0;
									let from_user_nickname = uni.getStorageSync(
											'roomchat_nickname') ??
										'';
									let from_user_avatar = uni.getStorageSync(
										'roomchat_user_avatar_file_name') ?? '';;



									let dataContent_z = uni.MBProtocalFactory.sendredpacket(
										this.reditem.from1, this.reditem.to1, this.reditem
										.nickname, typeu, JSON.stringify(m_z), this.reditem
										.contentType, Math.ceil(contentDuration / 1000),
										at, this.quoteinfo, this.reditem
										.userAvatar);

									console.log(dataContent_z);
									m_z.fp = this.reditem.fp;
									console.log(m_z);



									let dataContent_s = uni.MBProtocalFactory.sendredpacket(
										this.reditem.to1, this.reditem.from1,
										from_user_nickname, typeu, JSON.stringify(m_z), 13,
										Math.ceil(contentDuration / 1000),
										at, this.quoteinfo, this.reditem
										.userAvatar);


									let p = uni.MBProtocalFactory.createGroupDataSimple(this
										.fromUserId,
										from_user_nickname, this.reditem.from1,
										dataContent_s,
										typeu, at, 13, Math.ceil(contentDuration / 1000));
									p.time = uni.MBUtils.formatDate(new Date(),
										'yyyy-MM-dd hh:mm:ss');
									// if (this.isGroup == 0) {
									p.nickname = this.info.nickname;
									p.avatar = this.info.userAvatarFileName;
									p.gid = 0;
									// } else {
									// 	p.gid = receiver;
									// }

									uni.IMSDK.sendData(p);
									let dataContent_update_str = JSON.stringify(dataContent_z)

									let data = `dataContent = '${dataContent_update_str}'`;
									let where = `(fp = '${this.reditem.fp}')`
									// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
									DB.updateTableData("chat" + uni.getStorageSync(
												"roomchat_user_uid"),
											data, where)
										.then(res => {
											console.log(res);
										})
										.catch(error => {
											console.log("修改失败", error);
										});

									if (this.isGroup == 0) {
										if (this.reditem.to1 == uni.getStorageSync(
												'roomchat_user_uid')) {
											this.reditem.receive_name = uni.getStorageSync(
												'roomchat_nickname') ?? '';
											this.reditem.receive_avatar = uni.getStorageSync(
												'roomchat_user_avatar_file_name') ?? '';
										} else {
											this.reditem.receive_name = this.info.nickname
											this.reditem.receive_avatar = this.info.avatar
										}
									} else {
										let index = this.originalArray.findIndex(item => item
											.user_uid == this.reditem.dataContent
											.exclusive_uid)
										if (index >= 0) {
											this.reditem.receive_name = this.originalArray[
												index].nickname
											this.reditem.receive_avatar = this.originalArray[
												index].avatar
										} else {
											this.reditem.receive_name = ''
											this.reditem.receive_avatar = ''
										}

									}


									uni.navigateTo({
										url: '/pages/index/redreceiveInfo?item=' + JSON
											.stringify(this.reditem) + '&isGroup=' +
											this.isGroup,
										animationType: 'fade-in',
										animationDuration: 1,
									})
									this.packerState = 3;


								}, 500);
							})


						} else {
							this.$util.toast(res.data.message);
						}

					},
					fail: res => {
						console.log(res);
					}
				});
			},
			updategroupred() {
				uni.request({
					url: this.$api.baseUrl + '/api/user/money/grab-redbag',
					header: {
						'content-type': 'application/json'
					},
					data: {
						"redbag_id": this.reditem.dataContent.transferId,
						"user_id": uni.getStorageSync('roomchat_user_uid'),
					},
					method: 'POST',
					success: res => {
						console.log(this.$api.baseUrl)
						console.log(res)
						uni.hideLoading()
						if (res.data.code == 0) {
							this.packerState = 1;
							this.request(() => {
								// 调用抢红包接口成功，触发开红包动画
								this.packerState = 2;
								// 开红包动画结束后，移除相关节点，否则会阻挡其它下层节点
								setTimeout(() => {

									let m_z = this.reditem.dataContent;
									m_z.is_receive = 1;
									m_z.title = this.reditem.dataContent.title;
									m_z.price = this.reditem.dataContent.price;
									m_z.sendtime = this.reditem.dataContent.sendtime;
									m_z.receivetime = uni.MBUtils.formatDate(new Date(),
										'yyyy-MM-dd hh:mm:ss');
									m_z.transferId = this.reditem.dataContent.transferId;
									if (this.isGroup == 1) {
										m_z.isexclusive = this.reditem.dataContent.isexclusive;
										m_z.exclusive_uid = this.reditem.dataContent
											.exclusive_uid ?? '';
									}

									let typeu = 44;
									let at = [];
									if (this.isGroup == 0) {
										typeu = 3;
									}
									let contentDuration = 0;
									let from_user_nickname = uni.getStorageSync(
											'roomchat_nickname') ??
										'';
									let from_user_avatar = uni.getStorageSync(
										'roomchat_user_avatar_file_name') ?? '';;



									let dataContent_z = uni.MBProtocalFactory.sendredpacket(
										this.reditem.from1, this.reditem.to1, this.reditem
										.nickname, typeu, JSON.stringify(m_z), this.reditem
										.contentType, Math.ceil(contentDuration / 1000),
										at, this.quoteinfo, this.reditem
										.userAvatar);

									console.log(dataContent_z);
									m_z.fp = this.reditem.fp;
									console.log(m_z);



									let dataContent_s = uni.MBProtocalFactory.sendredpacket(
										this.reditem.to1, this.reditem.from1,
										from_user_nickname, typeu, JSON.stringify(m_z), 13,
										Math.ceil(contentDuration / 1000),
										at, this.quoteinfo, this.reditem
										.userAvatar);


									let p = uni.MBProtocalFactory.createGroupDataSimple(this
										.fromUserId,
										from_user_nickname, this.reditem.from1,
										dataContent_s,
										typeu, at, 13, Math.ceil(contentDuration / 1000));
									p.time = uni.MBUtils.formatDate(new Date(),
										'yyyy-MM-dd hh:mm:ss');
									// if (this.isGroup == 0) {
									p.nickname = this.info.nickname;
									p.avatar = this.info.userAvatarFileName;
									p.gid = 0;
									// } else {
									// 	p.gid = receiver;
									// }

									uni.IMSDK.sendData(p);
									let dataContent_update_str = JSON.stringify(dataContent_z)

									let data = `dataContent = '${dataContent_update_str}'`;
									let where = `(fp = '${this.reditem.fp}')`
									// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
									DB.updateTableData("chat" + uni.getStorageSync(
												"roomchat_user_uid"),
											data, where)
										.then(res => {
											console.log(res);
										})
										.catch(error => {
											console.log("修改失败", error);
										});

									if (this.isGroup == 0) {
										if (this.reditem.to1 == uni.getStorageSync(
												'roomchat_user_uid')) {
											this.reditem.receive_name = uni.getStorageSync(
												'roomchat_nickname') ?? '';
											this.reditem.receive_avatar = uni.getStorageSync(
												'roomchat_user_avatar_file_name') ?? '';
										} else {
											this.reditem.receive_name = this.info.nickname
											this.reditem.receive_avatar = this.info.avatar
										}
									} else {
										let index = this.originalArray.findIndex(item => item
											.user_uid == this.reditem.dataContent
											.exclusive_uid)
										if (index >= 0) {
											this.reditem.receive_name = this.originalArray[
												index].nickname
											this.reditem.receive_avatar = this.originalArray[
												index].avatar
										} else {
											this.reditem.receive_name = ''
											this.reditem.receive_avatar = ''
										}

									}


									uni.navigateTo({
										url: '/pages/index/redreceiveInfo?item=' + JSON
											.stringify(this.reditem) + '&isGroup=' +
											this.isGroup,
										animationType: 'fade-in',
										animationDuration: 1,
									})
									this.packerState = 3;



								}, 500);
							})


						} else {
							this.$util.toast(res.data.message);
						}

					},
					fail: res => {
						console.log(res);
					}
				});
			},
			request(success) {
				setTimeout(() => {
					success()
					console.log('success');
				}, 3000);
			},

			// 初始化滚动
			initScrollBar() {
				setTimeout(() => {
					this.scrollViewId = ''
					setTimeout(() => {
						this.scrollViewId = 'bottom'
						setTimeout(() => {
							this.scrollViewId = ''
						}, 100)
					}, 100)
				}, 100)
			},
			// 监听输入聚焦
			inputFocus(e) {
				console.log(e, 8988989)
				this.setScrollHeight(e.detail.height)
				this.initScrollBar()

				uni.onKeyboardHeightChange(res => {
					this.setScrollHeight(res.height)
					this.initScrollBar()
				})
			},
			// 设置scroll的高度
			setScrollHeight(descHeight = 0) {
				// #ifdef MP-WEIXIN
				this.scrollHeight = `calc(100vh - 110rpx - ${descHeight}px)`
				// #endif
				// #ifdef APP-PLUS
				this.scrollHeight = `calc(100vh - 300upx - ${descHeight}px)`
				// this.scrollTop = `calc(100vh - 220% - ${descHeight}px)`
				// #endif
				// #ifdef H5
				this.scrollHeight = `calc(100vh - 110upx - ${descHeight}px)`
				// #endif
			},
			// 切换选择
			togglePicker(height = 0, type = '') {
				this.showEmoji = false
				this.showFile = false
				let status = height > 0 ? true : false

				switch (type) {
					case 'emoji':
						this.showEmoji = status;
						break
					case 'file':
						this.showFile = status;
						break
				}

				setTimeout(() => {
					this.setScrollHeight(height)
					this.initScrollBar()
				}, 50)
			},
			// 切换语音与编辑
			toggleEdit(bool) {
				this.isEdit = bool
				this.isFocus = bool
				this.setScrollHeight(0)
			},
			//控制播放还是暂停音频文件
			handleAudio(item) {
				console.log(item);
				console.log(this.AudioExam);
				console.log(innerAudioContext.paused);
				if (!innerAudioContext.paused && this.AudioExam) {
					this.stopAudio(this.AudioExam);
					// this.closeAnmition();
				}
				if (innerAudioContext.paused) {

					this.AudioExam = item;
					console.log(this.AudioExam);
					this.playAudio(item);
				}
				// else {
				// 	this.AudioExam = item;
				// 	this.stopAudio(item);
				// }
			},
			//播放音频
			playAudio(item) {
				console.log(item);
				let user_uid = this.fromUserId;
				if (item.from1 != this.fromUserId) {
					user_uid = item.from1;
				}

				let src1 = 'http://chat.zwsmcn.com:8090/BinaryDownloader?action=voice_d&user_uid=' + user_uid +
					'&file_name=' +
					item.dataContent;
				let src = 'http://chat.zwsmcn.com:8090/voice/unread/' + item.dataContent;


				this.listData.forEach(item => {
					if (item.contentType === 2) { // 假设条件是对象的id等于2
						item.anmitionPlay = false
					}
				})

				console.log(src1);
				item.anmitionPlay = true;
				console.log(src);

				this.playMsgid = item.fp;
				innerAudioContext.src = src1;
				this.$nextTick(function() {
					innerAudioContext.play();
				});
			},
			//停止音频
			stopAudio(item) {
				innerAudioContext.stop();
				// item.anmitionPlay = false;

				const fp = this.playMsgid;
				const item1 = this.listData.find(it => it.fp == fp);
				item1.anmitionPlay = false;

				this.$forceUpdate();
			},
			//关闭动画
			closeAnmition() {
				const fp = this.playMsgid;
				const item = this.listData.find(it => it.fp == fp);
				item.anmitionPlay = false;

				this.$forceUpdate();
			},

			// checkRecordPermission(callback) {
			// 	const recorderManager = uni.getRecorderManager();
			// 	recorderManager.onStart(() => {
			// 		// 录音开始事件
			// 		callback(true); // 提供一个回调函数处理权限允许的情况
			// 	});
			// 	recorderManager.onError((err) => {
			// 		if (err.errMsg.indexOf('deny') !== -1 || err.errMsg.indexOf('denied') !== -1) {
			// 			// 用户拒绝了录音权限
			// 			callback(false); // 提供一个回调函数处理权限拒绝的情况
			// 		}
			// 	});
			// },
			//准备开始录音
			async startVoice(e) {
				let permisionID = '';
				permisionID = 'android.permission.RECORD_AUDIO';
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus
				if (result == 1) {
					strStatus = "已获得授权"
					if (!innerAudioContext.paused) {
						//如果音频正在播放 先暂停。
						this.stopAudio(this.AudioExam);
					}
					this.showVoice = true

					this.recording = true;
					this.isStopVoice = false;
					this.canSend = true;
					this.voiceIconText = '正在录音...';
					this.PointY = e.touches[0].clientY;
					recorderManager.start({
						format: 'wav'
					});
				} else if (result == 0) {
					strStatus = "未获得授权"
				} else {
					strStatus = "被永久拒绝权限"
					uni.showModal({
						content: permisionID + strStatus,
						showCancel: false
					});
				}

			},
			//录音已经开始
			beginVoice() {
				if (this.isStopVoice) {
					recorderManager.stop();
					return;
				}
				this.voiceTitle = '松开 结束';
				this.voiceInterval = setInterval(() => {
					this.voiceTime++;
				}, 1000);
			},
			//move 正在录音中
			moveVoice(e) {
				const PointY = e.touches[0].clientY;
				const slideY = this.PointY - PointY;
				if (slideY > uni.upx2px(120)) {
					this.canSend = false;
					this.voiceIconText = '松开手指 取消发送 ';
				} else if (slideY > uni.upx2px(60)) {
					this.canSend = true;
					this.voiceIconText = '手指上滑 取消发送 ';
				} else {
					this.voiceIconText = '正在录音... ';
				}
			},
			//结束录音
			endVoice() {
				this.showVoice = false

				this.isStopVoice = true; //加锁 确保已经结束录音并不会录制
				this.recording = false;
				recorderManager.stop();
				this.voiceTitle = '按住 说话';
			},
			//录音被打断
			cancelVoice(e) {
				this.voiceTime = 0;
				this.voiceTitle = '按住 说话';
				this.canSend = false;
				recorderManager.stop();
			},
			//处理录音文件
			handleRecorder({
				tempFilePath,
				duration
			}) {
				console.log(tempFilePath);

				clearInterval(this.voiceInterval);

				let contentDuration;

				contentDuration = (parseInt(this.voiceTime) + 1) * 1000;


				if (contentDuration <= 0) {
					this.voiceIconText = '说话时间过短';
					setTimeout(() => {
						this.recording = false;
					}, 200);
					return;
				}

				this.recording = false;

				//是否发送语音
				if (!this.canSend) {
					return;
				}
				let filePath = tempFilePath;

				let Paths = this.$md5(filePath);
				let Filetype = filePath.substring(filePath.lastIndexOf('.'));
				let files = {
					file_name: Paths + Filetype,
				}
				plus.io.resolveLocalFileSystemURL(
					filePath,
					entry => { //获取文件对象  
						console.log("entry:" + entry.fullPath);
						plus.io.resolveLocalFileSystemURL(
							"_downloads",
							entry22 => { //获取文件对象  
								console.log("entry223:" + entry22.fullPath);
								var nname = Paths + Filetype
								entry.copyTo(entry22, nname, newimage => {
										console.log("808");
										console.log(newimage.fullPath);
										uni.uploadFile({

											url: 'http://chat.zwsmcn.com:8090/MsgVoiceUploader',
											// url: 'http://192.168.0.123:8080/rainbowchat_server/MsgImageUploader',
											header: {
												'content-type': 'multipart/form-data',
											},
											filePath: 'file://' + newimage.fullPath,
											// files:files,
											name: nname, //'file',
											fileName: nname,
											formData: {
												user_uid: this.fromUserId,
												file_name: Paths + Filetype,
												fileName: Paths + Filetype,
												token: '999999999999999_token' //uni.getStorageSync('coding_imtoken'),
											},
											method: 'post',
											success: res => {
												if (res.statusCode == 200) {
													this.sendGroupMssage(Paths + Filetype, 2);
												}
											},
											fail: res => {
												console.log(res);
											}
										});
									},
									newimage => {
										console.log("808err");
										console.log(newimage);
									});


							}
						)



					}
				)


			},

			uploadMsgImage(filePath, nname) {
				// uni.showModal({
				// 	content: filePath,
				// })
				uni.uploadFile({
					url: this.$api.baseUrl + '/api/v1/common/upload',
					header: {
						'content-type': 'multipart/form-data'
					},
					filePath: filePath,
					name: 'file',
					data: {
						file: filePath,
					},
					success: (res) => {
						console.log(res);

						if (res.data.code == 0) {
							let img_item = JSON.parse(res.data);
							this.sendGroupMssage(img_item.data.url, 1);
						}
					},
					fail: res => {
						console.log(res);
					}
				});
				return;



				uni.uploadFile({

					url: 'http://chat.zwsmcn.com:8090/MsgImageUploader',
					// url: 'http://192.168.0.123:8080/rainbowchat_server/MsgImageUploader',
					header: {
						'content-type': 'multipart/form-data',
					},
					filePath: filePath,
					// files:files,
					name: nname, //'file',
					fileName: nname,
					formData: {
						user_uid: this.fromUserId,
						file_name: nname,
						fileName: nname,
						token: '999999999999999_token' //uni.getStorageSync('coding_imtoken'),
					},
					method: 'post',
					success: res => {
						if (res.statusCode == 200) {
							this.sendGroupMssage(nname, 1);
						}
					},
					fail: res => {
						console.log(res);
					}
				});
				return;
				// this.$util.loading('上传中')

			},
			uploadMsgVideo(filePath, nname, video_info, Paths) {
				let filename = filePath.substring(filePath.lastIndexOf('/'));
				filename = filename.replace('/', '');
				uni.uploadFile({

					url: 'http://chat.zwsmcn.com:8090/ShortVideoUploader',
					header: {
						'content-type': 'multipart/form-data',
					},
					filePath: filePath,
					// files:files,
					name: nname, //'file',
					fileName: nname,
					formData: {
						name: Paths,
						user_uid: this.fromUserId,
						file_name: nname,
						chunks: 1,
						chunk: 1,
						totalLength: video_info.size,
						totalFileMd5: nname,
						token: '999999999999999_token' //uni.getStorageSync('coding_imtoken'),
					},
					method: 'post',
					success: res => {
						console.log(filePath);
						console.log(nname);
						console.log(res);
						let dataContent = {};


						dataContent.fileMd5 = Paths
						dataContent.fileLength = video_info.size
						dataContent.fileName = nname
						dataContent.width = video_info.width
						dataContent.height = video_info.height


						if (res.statusCode == 200) {
							this.sendGroupMssage(JSON.stringify(dataContent), 6);
						}
					},
					fail: res => {
						console.log(res);
					}
				});
				return;
				// this.$util.loading('上传中')

			},

			// 播放录音
			playVoice(item) {
				if (this.voicePlayingId) {
					this.voicePlayingId = ''
				} else {
					this.voicePlayingId = item.id
					innerAudioContext.src = item.content
					innerAudioContext.play()
				}
			},
			// 长按
			longPress(msg) {
				let data = {
					type: 'single',
					source: this.fromUserId,
					dest: this.toUserId,
					timestamp: new Date().getTime(),
					msg: {
						id: msg.id,
						fromUserId: msg.fromUserId,
						toUserId: msg.toUserId,
						type: 'cancel',
						content: msg.content
					}
				}

				uni.sendSocketMessage({
					data: JSON.stringify(data),
					success: res => {
						// 撤销本地消息
						this.list = this.list.map(item => {
							item.type = item.id == msg.id ? 'cancel' : item.type
							return item
						})
					}
				})
			},
			// 获取位置
			getLocation() {
				console.log('getLocation');
				uni.getLocation({
					success: res => {
						console.log(res);
						let {
							latitude,
							longitude
						} = res
						uni.chooseLocation({
							latitude,
							longitude,
							success: chooseRes => {
								console.log(chooseRes);


								this.sendGroupMssage(JSON.stringify(chooseRes), 8);
							}
						})
					},
					fail: res => {
						console.log(res);
					}
				})
			},
			// 打开位置
			openLocation(content) {
				let {
					latitude,
					longitude
				} = JSON.parse(content)
				uni.openLocation({
					latitude,
					longitude
				})
			},
			uploadMedia() {
				console.log('uploadMedia');
				uni.chooseMedia({
					mediaType: ['image', 'video'], // 选择媒体类型，可选值有'image'（图片）、'video'（视频）
					sourceType: ['album', 'camera'], // 选择源类型，可选值有'album'（相册）、'camera'（相机）
					success: (res) => {
						console.log(res.tempFiles);
						// 成功选取媒体后的回调函数
						if (res.type === 'image') {
							for (let i = 0; i < res.tempFiles.length; i++) {

							}
						} else if (res.type === 'video') {

						}
					},
					fail: (err) => {
						// 选择媒体失败的回调函数
						console.error('选择媒体失败:', err);
					}
				})
			},
			blobToFile(blob, fileName) {
				return new File([blob], fileName, {
					type: 'image/png'
				})
			},
			// 发送图片
			uploadImage() {
				//#ifdef H5
				uni.chooseFile({
					count: 10, //最多可以选择的文件数量，默认100
					type: 'image', //所选的文件的类型image,video,pdf等，默认all
					//extension:['.png','.zip','.doc'],//根据文件拓展名过滤，每一项都不能是空字符串。默认不过滤。暂只支持文件后缀名，例如['.zip','.exe','.js']，不支持application/msword等类似值
					sourceType: ['album', 'camera'],
					success: res => {
						let tempFilePaths = res.tempFiles;
						for (let i = 0; i < tempFilePaths.length; i++) {

							console.log(tempFilePaths[i]);
							console.log(tempFilePaths[i].path);


							let Filetype = tempFilePaths[i].name.substring(tempFilePaths[i].name.lastIndexOf(
								'.'));

							// const imgBlob = fetch();
							const filItem = new File([tempFilePaths[i].path], tempFilePaths[i].name, {
								type: tempFilePaths[i].type
							});
							const formdata = new FormData();
							formdata.append("file", filItem);
							console.log(formdata);


							uni.uploadFile({
								url: 'http://123.57.231.99:8091/api/v1/common/upload', //七牛上传接口，仅为示例
								filePath: tempFilePaths[i].path,
								name: 'file',
								formData: {
									// 'token': token
								},
								success: (f_res) => {
									let File_res = JSON.parse(f_res.data);
									if (File_res.code == 0) {
										// let img_item = JSON.parse(res.data);
										this.sendGroupMssage(File_res.data.url, 1);
									}
								},
							});
						}
					},
					fail(err) {
						//接口调用失败
						console.log('失败' + err)
					},
					complete(result) {
						//接口调用结束（调用成功、失败）
						// this.$emit('getFile', result)
					}
				})
				//#endif
				return;

				uni.chooseImage({
					sourceType: ['album', 'camera'],
					success: chooseImageRes => {
						const tempFilePaths = chooseImageRes.tempFilePaths;

						for (let i = 0; i < tempFilePaths.length; i++) {


							let Paths = this.$md5(tempFilePaths[i]);
							let Filetype = tempFilePaths[i].substring(tempFilePaths[i].lastIndexOf('.'));
							let files = {
								file_name: Paths + Filetype,
							}
							fetch(tempFilePaths[i].url)
								.then(response => response.blob())
								.then(blob => {
									let fileN = this.blobToFile(blob, tempFilePaths[i].name)
									console.log(fileN);
									this.uploadMsgImage(tempFilePaths[i], Paths + Filetype);
								})
						}
						return;

					}
				})
			},

			// 发送视频
			uploadVideo() {


				uni.chooseVideo({
					sourceType: ['camera', 'album'],
					compressed: false,
					success: chooseImageRes => {
						console.log(chooseImageRes);

						const tempFilePaths = chooseImageRes.tempFilePath;

						let video_info = {};
						video_info.size = chooseImageRes.size;
						video_info.duration = chooseImageRes.duration;
						video_info.width = chooseImageRes.width;
						video_info.height = chooseImageRes.height;
						console.log(tempFilePaths);



						let Paths = this.$md5(tempFilePaths);
						let Filetype = tempFilePaths.substring(tempFilePaths.lastIndexOf('.'));
						let files = {
							file_name: Paths + Filetype,
						}
						plus.io.resolveLocalFileSystemURL(
							tempFilePaths,
							entry => { //获取文件对象  
								console.log("entry:" + entry.fullPath);
								plus.io.resolveLocalFileSystemURL(
									"_downloads",
									entry22 => { //获取文件对象  
										console.log("entry223:" + entry22.fullPath);
										var nname = Paths + Filetype
										entry.copyTo(entry22, nname, newimage => {
												console.log("808");
												console.log(newimage.fullPath);
												this.uploadMsgVideo('file://' + newimage
													.fullPath, nname, video_info, Paths);

											},
											newimage => {
												console.log("808err");
												console.log(newimage);
											});


									}
								)



							}
						)


					}
				})
			},

			// 发送	文件
			uploadFile() {
				uni.chooseFile({
					extension: ['.zip', '.doc'],
					success: chooseImageRes => {

						const tempFilePaths = chooseImageRes.tempFilePaths;

						let Paths = this.$md5(tempFilePaths);
						let Filetype = tempFilePaths.substring(tempFilePaths.lastIndexOf('.'));
						let files = {
							file_name: Paths + Filetype,
						}
						plus.io.resolveLocalFileSystemURL(
							tempFilePaths,
							entry => { //获取文件对象  
								console.log("entry:" + entry.fullPath);
								plus.io.resolveLocalFileSystemURL(
									"_downloads",
									entry22 => { //获取文件对象  
										console.log("entry223:" + entry22.fullPath);
										var nname = Paths + Filetype
										entry.copyTo(entry22, nname, newimage => {
												console.log("808");
												console.log(newimage.fullPath);

											},
											newimage => {
												console.log("808err");
												console.log(newimage);
											});


									}
								)



							}
						)


					}
				})
			},
			// 发送消息
			sendgroup() {
				// 聊天消息接收者
				var receiver = this.receiverInput;
				// 聊天消息内容

				var message = this.content;
				// 网络连接正常的情况下才允许发送消息哦
				// if (receiver && message && uni.IMSDK.isOnline()) {

				if (message) {
					this.sendGroupMssage(message, 0);
				}
			},
			send() {
				// 聊天消息接收者
				var receiver = this.receiverInput;
				var message = this.content;
				// 网络连接正常的情况下才允许发送消息哦
				// if (receiver && message && uni.IMSDK.isOnline()) {
				if (message) {
					this.sendGroupMssage(message, 0);

				}
			},
			// 	////发送单人聊天消息chat_type:0文字消息 1图片消息2语音留言消息3赠送的礼品消息4索取礼品消息5文件消息6短视频消息7名片消息8位置消息9实时音视频记录消息90系统消息或提示信息91消息撤回
			// 10红包11笔记12转账13红包领取14转账接受

			sendGroupMssage(message, chat_type) {

				var receiver = this.receiverInput;

				if (receiver && message && receiver != null && receiver != '' && receiver != 'undefined') {
					let typeu = 44;
					let srcNickName = uni.getStorageSync('roomchat_nickname') ??
						''; // nickname;// this.info.g_notice_updatenick;//nickname;//'';
					let from_user_avatar = uni.getStorageSync('roomchat_user_avatar_file_name') ?? '';;
					let at = this.atList;

					if (this.isGroup == 0) {
						typeu = 3;
						srcNickName = uni.getStorageSync('roomchat_nickname') ?? '';
					}
					let contentDuration = 0;
					if (chat_type == 2) {

						contentDuration = (parseInt(this.voiceTime) + 1) * 1000;

					}

					typeu = this.typeu;


					let dataContent = this.senddataContent(typeu, message, chat_type, Math.ceil(contentDuration / 1000),
						at);
					console.log(dataContent)

					let p = uni.MBProtocalFactory.createGroupDataSimple(this.fromUserId,
						srcNickName, receiver, dataContent,
						typeu, at, chat_type, Math.ceil(contentDuration / 1000));

					p.time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
					if (this.isGroup == 0) {
						p.nickname = this.info.nickname;
						p.avatar = this.info.userAvatarFileName;
						p.gid = 0;
					} else {
						p.gid = receiver;
					}

					uni.IMSDK.sendData(p);

					let update_data = JSON.parse(p.dataContent);
					let dataContent1 = JSON.parse(p.dataContent);

					if (chat_type == 91) {
						update_data.m = '消息撤回';
						let update_data_str = JSON.stringify(update_data);
						p.dataContent = update_data_str;
						if (dataContent1.m.indexOf('fpForMessage') >= 0) {
							let m = JSON.parse(dataContent1.m)
							let data = `dataContent = '${update_data_str}'`;

							let where = `fp = '${m.fpForMessage}'`
							// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
							// DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
							// 	.then(res => {
							// 		p.time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');

							// 		let f_index = this.listData.findIndex(item => item.fp == m
							// 			.fpForMessage)
							// 		if (f_index >= 0) {
							// 			let chatMsg = that.constructMessage(p);
							// 			this.listData[f_index] = chatMsg;
							// 		}
							// 		// 添加聊天消息到ui消息列表中

							// 	})
							// 	.catch(error => {
							// 		console.log("修改失败", error);
							// 	});
						}
					} else if (dataContent.ty == 13 || dataContent.ty == 14) {
						let m_z = JSON.parse(dataContent.m);
						m_z.receivetime = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
						m_z.is_receive = 1;
						if (dataContent.ty == 13) {
							update_data.ty = 10;
						} else {
							update_data.ty = 12;
						}

						let where = `(fp = '${m_z.fp}')`
						update_data.m = JSON.stringify(m_z);
						let update_data_str = JSON.stringify(update_data);
						let data = `dataContent = '${update_data_str}'`;
						// DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
						// 	.then(res => {

						// 	})
						// 	.catch(error => {
						// 		console.log("修改失败", error);
						// 	});
					} else if (chat_type == 20) {
						// let chatMsg = this.constructMessage(p);
						// this.listData.push(chatMsg);
						// this.insertTableData(p)
					} else {
						let chatMsg = this.constructMessage(p);
						this.listData.push(chatMsg);

						console.log(p);
						// this.insertTableData(p)
					}


					// 自动滚动到列表底部
					this.scrollToBottom();




					this.atList = [];
					this.voiceTime = 0;
					this.quoteinfo = {};
					// 清空输入框
					this.content = "";
				} else {

					if (!receiver) {
						uni.MBUtils.alert('消息接收者是空的！');
					} else if (receiver == null || receiver == '' || receiver == 'undefined') {
						uni.MBUtils.alert('消息接收者是空的！');
					} else if (!message) {
						uni.MBUtils.alert('要发送的内容是空的！');
					} else if (!uni.IMSDK.isOnline()) {
						uni.MBUtils.alert('online==false, 当前已离线，无法发送消息！');
					}
				}

			},
			// dataContent_z
			senddataContent(typeu, dataContent, chat_type, contentDuration, at) {
				let from_user_id = this.fromUserId;
				let from_user_nickname = '患者'; // uni.getStorageSync('roomchat_nickname') ?? '';;
				let from_user_avatar = this.fromUserFace; //uni.getStorageSync('roomchat_user_avatar_file_name') ?? '';;

				let to_user_id = this.receiverInput;
				var dataContent_z = {};
				let fingerPrint = null
				let QoS = true;

				dataContent_z.at = at;
				dataContent_z.QoS = QoS;
				dataContent_z.nickName = from_user_nickname;
				dataContent_z.userAvatar = from_user_avatar;
				dataContent_z.receivernickName = this.info.g_name;
				dataContent_z.receiveruserAvatar = this.info.image ?? this.info.userAvatar;
				dataContent_z.cy = 2;
				dataContent_z.f = from_user_id;
				dataContent_z.m = dataContent;
				dataContent_z.t = to_user_id;
				dataContent_z.g_name = this.info.g_name;
				dataContent_z.ty = chat_type;
				dataContent_z.quote_status = 0;
				dataContent_z.quote_type = this.quoteinfo.contentType ?? 0;
				dataContent_z.quote_fp = this.quoteinfo.fp ?? '';
				dataContent_z.quote_sender_uid = this.quoteinfo.from1 ?? '';
				dataContent_z.quote_sender_nick = this.quoteinfo.nickname ?? '';
				dataContent_z.quote_content = this.quoteinfo.dataContent ?? '';
				if (chat_type == 2) {
					dataContent_z.contentDuration = contentDuration;
				}




				return dataContent_z;
			},



			// 获取信息
			getQuicklist() {
				uni.request({
					url: this.$api.baseUrl + '/api/common/post/fetch',
					header: {
						'content-type': 'application/json'
					},
					data: {
						user_id: uni.getStorageSync('roomchat_user_uid'),
						post_type: 4,
					},
					method: 'POST',
					success: res => {

						if (res.data.code == 0) {
							this.Quicklist = res.data.data;
						}
					},
					fail: res => {
						console.log(res);
					}

				})
			},
			// 获取记录
			getList() {
				uni.request({
					url: this.$api.getSingleRecord,
					data: {
						fromUserId: this.fromUserId,
						toUserId: this.toUserId
					},
					header: this.$util.getHeader(),
					success: res => {
						this.list = res.data.data.map(item => {
							if (['voice', 'image'].includes(item.type)) {
								item.content = this.$api.staticPath + item.content
							}
							if (item.toUserFace) {
								item.toUserFace = this.$api.staticPath + item.toUserFace
							}

							// 为了和socket的字段一致，此处做一个转换；
							// 数据表字段可以直接设置为source、target和msgType
							item.source = item.fromUserId
							item.target = item.toUserId
							item.msgType = item.type
							return item
						})

						this.scrollViewId = ''
						setTimeout(() => {
							this.scrollViewId = 'bottom'
							setTimeout(() => {
								this.scrollViewId = ''
							}, 100)
						}, 100)
					}
				})
			},
			getforbidlist() {
				uni.request({
					url: this.$api.baseUrl + '/api/group/forbid/list',
					header: {
						'content-type': 'application/json'
					}, // this.$util.getHeader(),
					data: {
						g_id: this.info.g_id,
						page: 1,
						page_size: 50,
					},
					method: 'POST',
					success: res => {
						console.log(res);
						if (res.data.code == 0) {
							let list = res.data.data;
							let index = list.findIndex(item => (item.user_uid == uni.getStorageSync(
								'roomchat_userId')));
							if (index >= 0) {
								this.isForbid = true;
							} else {
								this.isForbid = false;
							}
						}

						// this.list = res.data;
					},
					fail: res => {
						console.log(res);
					}

				})
			},

			getchatlist() {
				//  

				this.listData = [];
				console.log('getchatlist');
				const newDataObj = {
					"gid": this.info.g_id, //  被查群 id
					"luid": this.fromUserId, // 用户或好友的 mail 地址
					"orderby": 0, // 排序方式： 1 表示按消息时间 DESC 逆序，0 表示按消息时间 ASC 顺序排序
					'starttime': '',
					'endtime': ''
				};
				const newDataJsonStr = JSON.stringify(newDataObj)
				const requestData = {
					"processorId": '1008',
					"jobDispatchId": '26',
					"actionId": '8',
					// "token":uni.getStorageSync('token'), 
					"newData": newDataJsonStr
				};
				const requestDataJsonStr = JSON.stringify(requestData);

				console.log(requestDataJsonStr)
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestData, // requestDataJsonStr,
					method: 'POST',
					success: res => {

						let arr = JSON.parse(res.data.returnValue);
						arr.map((subArr) => {
							var dataContent_z = {};


							dataContent_z.at = []; // at;
							dataContent_z.QoS = true;
							dataContent_z.nickName = subArr[14];
							dataContent_z.cy = 2;
							dataContent_z.f = subArr[0];
							dataContent_z.m = subArr[4];
							dataContent_z.t = subArr[1];
							dataContent_z.ty = subArr[3];
							dataContent_z.quote_status = '';
							dataContent_z.quote_type = '';
							dataContent_z.parentFp = '';




							console.log('-------122122');
							let p = uni.MBProtocalFactory.createGroupProtocal(subArr[3], JSON
								.stringify(dataContent_z), subArr[0], subArr[1], true,
								null,
								subArr[4]);

							p.to = uni.getStorageSync("roomchat_user_uid");
							if (subArr[0]) {
								// item.history_time2.length > 10 ? item.history_time2.slice(0, -3):item.history_time2 
								p.time = this.$util.turnTime_Java(Number(subArr[5]),
									'seconds')
							}

							let chatMsg = this.constructMessage(p);

							console.log(chatMsg);
							if (subArr[3] != 90) {
								this.listData.push(chatMsg);
							}


						});

						this.$forceUpdate();
						console.log(this.listData)

					},
					fail: res => {
						console.log(res);
					}
				});
			},
			topConFirm() {
				console.log('topConFirm')
				let where = '';
				let data = '';
				let is_top = 0;
				if (this.info.is_top == 0) {
					is_top = 1;
				} else {
					is_top = 0;
				}
				let tophashMap = uni.getStorageSync('tophashMap' + uni.getStorageSync("roomchat_user_uid"));
				if (tophashMap) {
					tophashMap = new Map(JSON.parse(tophashMap));
					tophashMap.set(this.info.relatedId, Boolean(is_top));
					uni.setStorageSync('tophashMap' + uni.getStorageSync("roomchat_user_uid"), JSON.stringify(Array.from(
						tophashMap)))
				} else {
					tophashMap = new Map();
					tophashMap.set(this.info.relatedId, Boolean(is_top));
					uni.setStorageSync('tophashMap' + uni.getStorageSync("roomchat_user_uid"), JSON.stringify(Array.from(
						tophashMap)))
				}

				console.log(uni.getStorageSync('tophashMap' + uni.getStorageSync("roomchat_user_uid")));
				this.info.is_top = is_top;
				data = `is_top = ${is_top}`
				where = `relatedId = '${this.info.relatedId}'`
				this.DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
					.then(res => {
						console.log(res);
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			muteConFirm() {
				console.log('muteConFirm')
				let where = '';
				let data = '';
				let is_mute = 0;
				if (this.info.is_mute == 0) {
					is_mute = 1;
				} else {
					is_mute = 0;
				}
				let disturbhashMap = uni.getStorageSync('disturbhashMap' + uni.getStorageSync("roomchat_user_uid"));
				if (disturbhashMap) {
					disturbhashMap = new Map(JSON.parse(disturbhashMap));
					disturbhashMap.set(this.info.relatedId, Boolean(is_mute));
					uni.setStorageSync('disturbhashMap' + uni.getStorageSync("roomchat_user_uid"), JSON.stringify(Array
						.from(
							disturbhashMap)))
				} else {
					disturbhashMap = new Map();
					disturbhashMap.set(this.info.relatedId, Boolean(is_mute));
					uni.setStorageSync('disturbhashMap' + uni.getStorageSync("roomchat_user_uid"), JSON.stringify(Array
						.from(
							disturbhashMap)))
				}
				this.info.is_mute = is_mute;
				console.log(is_mute)
				console.log(uni.getStorageSync('disturbhashMap' + uni.getStorageSync("roomchat_user_uid")))
				data = `is_mute = ${is_mute}`
				where = `relatedId = '${this.info.relatedId}'`

				this.DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
					.then(res => {
						console.log(res);
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			recordsConFirm() {
				console.log('recordsConFirm')
				let data = `del_flag = 1`;
				let where = `(relatedId = '${this.info.relatedId}')`
				// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
				this.DB.updateTableData("chat" + uni.getStorageSync("roomchat_user_uid"), data, where)
					.then(res => {
						console.log(res);
						this.selectTableData();
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			getDetail() {
				uni.request({
					url: this.$api.baseUrl + '/api/group/get/info',
					header: {
						'content-type': 'application/json'
					},
					data: {
						g_id: this.info.g_id
					},
					method: 'POST',
					success: res => {
						console.log(res);
						if (res.data.code == 0) {

							this.info = res.data.data;
							this.info.relatedId = this.info.g_id;

							console.log(this.info);
						}
					},
					fail: res => {
						console.log(res);
					}

				})
			},



		}
	}
</script>

<style lang="scss" scoped>
	.head-top {
		width: 92%;
		height: 148upx;
		margin: 0 auto;
		// background: #ffffff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		z-index: 999999;
		background-color: #FFF;
		margin-top: 40upx;

		.topname {
			width: 50%;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			text-align: center;
		}
	}

	.container {
		height: 100vh;
		overflow: hidden;
		background-color: #F3F3F3;
		overflow: hidden;
	}

	/* #ifdef H5 */
	.container {
		height: calc(100vh - 288upx);
		background: red;
		// background-color: #fff;
		overflow: hidden;
	}

	page,
	.container2 {
		width: 100%;
		height: 100%;
		overflow: hidden;
	}

	/* #endif */

	.status_bar,
	.container,
	.header,
	.emoji,
	.file {
		background-color: #F3F3F3;
	}

	.header {
		border-bottom: 2upx solid #EEE;

		.center {
			font-weight: bold;
		}
	}

	.map {
		width: 60%;
		height: 300upx;
		background-color: #FFF !important;

		&::before {
			border-right: 30upx solid #FFF !important;
		}

		.title {
			height: 80upx;
			font-size: 28upx;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
		}

		.box {
			width: 100%;
			height: 170upx;
			margin-top: 10upx;
		}
	}

	.emoji {
		height: 400upx;
		padding: 0 0 20upx 20upx;
		background-color: #ffffff;
		// position: fixed;
		// bottom: 0;

		.img-active {
			background-color: #F3F3F3;
			border-radius: 5px;
		}

		.item {
			float: left;
			display: block;
			height: 60upx;
			line-height: 60upx;
			width: calc(100% / 12);
			margin-left: 20upx;
		}
	}



	.file {
		padding: 10upx 20upx;
		background-color: #FFF;
		// position: fixed;
		// bottom: 0;


		.list {
			overflow: hidden;
			padding-left: 10upx;
			justify-content: flex-start;
		}

		.item {
			float: left;
			width: 110upx;
			height: 110upx;
			border-radius: 10upx;
			margin-right: 40upx;
			background-color: #EEE;

			.icon {
				width: 50upx;
			}

			.text {
				font-size: 24upx;
				margin-top: 4upx;
			}
		}
	}

	.uni-input-wrapper {
		background-color: #eee;
	}

	.more-item {
		display: flex;
		align-items: center;
	}

	.oper {
		min-height: 110upx;
		padding: 0 20upx;
		box-sizing: border-box;
		border-top: 2upx solid #EEE;

		display: flex;
		flex-direction: row;
		align-items: center;
		overflow: hidden;



		// border-bottom: 2upx solid #EEE;
		.input-box {

			width: calc(100% - 120upx - 20upx - 40upx - 60upx);
		}

		.input-box-quote {
			font-size: 12px;
			padding: 5px;
			background-color: #ededed;
			border-radius: 5px;
			color: #999;
			display: -webkit-box;
			/* 作为弹性伸缩盒子模型显示 */
			-webkit-box-orient: vertical;
			/* 设置盒子的垂直排列 */
			-webkit-line-clamp: 1;
			/* 限制在两行 */
			overflow: hidden;
			/* 超出的文本隐藏 */
			text-overflow: ellipsis;
			/* 多出的文本用省略号表示 */
			line-height: 1.5;
			/* 行高，可以根据需要调整 */
			height: 1.5em;
			/* 最大高度为1.5em*2=3em */
			white-space: normal;
			/* 使用正常的白空格处理方式，允许换行 */
			word-break: break-all;
			/*允许字符间能自动换行（英文字符、数字等）*/
			box-sizing: content-box;

			text {
				font-size: 12px;
			}
		}

		.input {
			height: 78upx;
			line-height: 78upx;
			padding: 0 20upx;
			font-size: 28upx;
			border-radius: 10upx;
			background-color: #eee;
			border-radius: 20px;
			// width: calc(100% - 120upx - 20upx - 40upx - 60upx);
			width: 100%;
			border: 1px solid #ebe6e6;
		}

		.icon {
			width: 60upx;
			height: 60upx;
		}

		.icon-send {
			width: 60upx;
			height: 60upx;
			background-color: #ededed;
			padding: 5px;
			border-radius: 50%;

			&.active {
				background-color: #007aff;
			}
		}

		.btn {
			color: #fff;
			width: 90upx;
			height: 52upx;
			font-size: 24upx;
			line-height: 52upx;
			text-align: center;
			border-radius: 10upx;
			background-color: #2BA245;
		}
	}

	.scroll {
		overflow-y: auto;
		overflow: hidden;
		transition: all 0.1s ease;
		height: calc(100vh - 88upx - 110upx - var(--status-bar-height));

		/* #ifdef MP-WEIXIN */
		height: calc(100vh - 88upx - var(--status-bar-height));
		/* #endif */
		/* #ifdef H5 */
		height: calc(100vh - 88upx - 110upx - var(--status-bar-height));

		width: 100%;

		/* #endif */

		// background-color: #00D4E2;
		//background: yellow;


		.message-box {
			display: flex;
			align-items: center;

		}


		.item-space {
			height: 30upx;
		}

		.time {
			color: #666;
			font-size: 24upx;
			text-align: center;
			margin-bottom: 20upx;
		}

		.cancel {
			width: 100%;
			height: 40upx;
			text-align: center;
			margin-bottom: 30upx;

			.text {
				color: #999;
				font-size: 24upx;
			}
		}

		.item {
			margin: 0 30upx 30upx;
			align-items: flex-start;
			justify-content: flex-start;

			.face {
				width: 80upx;
				height: 80upx;
				border-radius: 10upx;
			}

			.content {
				color: #000;
				font-size: 32upx;
				min-height: 80upx;
				border-radius: 10upx;
				padding: 20upx 24upx;
				background-color: #fff;
				word-break: break-all;
				word-wrap: break-word;
				max-width: calc(100% - 100upx - 120upx);
				position: relative;

				&::before {
					content: '';
					width: 0;
					height: 0;
					border-right: 30upx solid #FFF;
					border-top: 20upx solid transparent;
					border-bottom: 20upx solid transparent;
					position: absolute;
					top: 24upx;
				}

				.voice-icon {
					width: 32upx;
					height: 40upx;
					margin-right: 180upx;
					margin-bottom: -8upx;
				}
			}

			&.left {
				.face {
					margin-right: 30upx;
				}

				.content::before {
					left: -20upx;
				}
			}

			&.right {
				flex-direction: row-reverse;

				.face {
					margin-left: 30upx;
				}

				.content {
					background-color: #A0EA6F;

					&::before {
						right: -20upx;
						transform: rotate(180deg);
						border-right: 30upx solid #A0EA6F;
					}

					.voice-icon {
						margin-right: 0;
						margin-left: 180upx;
						transform: rotate(180deg);
					}
				}
			}
		}

		#bottom {
			height: 0;
		}
	}

	.boxlist {
		width: 100%;
		// background: red;
		height: calc(100vh - 230upx);


	}

	.chat-container {
		display: flex;
		flex-direction: column;
		height: 100vh;
		background-color: #f8f8f8;
	}

	.chat-content {
		flex: 1;
		padding: 10px;
		overflow-y: auto;
	}

	.message-avatar {
		width: 40px;
		height: 40px;
		border-radius: 50%;
		margin-right: 10px;
		overflow: hidden;
		margin-left: 20upx;
	}

	.message-body {
		max-width: 70%;
		background-color: #e5e5ea;
		border-radius: 10px;
		padding: 8px;
		word-break: break-all;
		//margin-right: 5%;
	}

	.quote-message-body {
		max-width: 80%;
		background-color: #e5e5ea;
		border-radius: 10px;
		padding: 8px;
		word-break: break-all;
		font-size: 12px;
		margin-left: auto;
		//margin-right: 5%;
		display: flex;
		align-items: center;
		float: right;
	}

	.quote-message-body1 {
		max-width: 80%;
		background-color: #e5e5ea;
		border-radius: 10px;
		padding: 8px;
		word-break: break-all;
		font-size: 12px;
		margin-left: 10px;
		display: flex;
		align-items: center;
		float: left;
	}

	.circle-message-body {
		max-width: 80%;
		background-color: #e5e5ea;
		border-radius: 10px;

		word-break: break-all;
		font-size: 12px;
		margin-left: auto;
		//margin-right: 5%;
		display: flex;
		flex-direction: column;
		// align-items: center;
		float: right;
	}

	.circle-message-body1 {
		max-width: 80%;
		background-color: #e5e5ea;
		border-radius: 10px;

		word-break: break-all;
		font-size: 12px;
		margin-left: 10px;
		display: flex;
		flex-direction: column;
		// align-items: center;
		float: left;
	}

	.message-img {
		max-width: calc(70vw - 110rpx);
		max-height: calc(70vw - 110rpx);
		border-radius: 10px;
		// position: relative;
		// word-break: break-all;
		// float: right;
		margin-left: auto;
	}

	.message-img1 {
		max-width: calc(70vw - 110rpx);
		max-height: calc(70vw - 110rpx);
		border-radius: 10px;

		// position: relative;
		// word-break: break-all;
		// float: left;
	}

	.message-red {
		width: calc(calc(70vw - 110rpx)*1);
		margin-left: 30vw;
		word-break: break-all;
	}

	.message-red1 {
		width: calc(calc(70vw - 110rpx)*1);
		margin-right: 30vw;
		word-break: break-all;
	}

	.self {
		margin-left: auto;
		background-color: #0084ff;
		color: white;
	}

	.self1 {
		//margin-left: auto;
		background-color: #e6e6ac;
		color: white;
		// margin-left: 10px;
	}

	.self-video {
		width: calc(calc(70vw - 110rpx)*1);
		border-radius: 10px;
		padding: 8px;
		word-break: break-all;
		margin-left: auto;
		color: white;
		float: right;

		display: flex;
		flex-direction: column;
		// align-items: center;
		justify-content: center;
	}

	.self-video1 {
		width: calc(calc(70vw - 110rpx)*1);
		border-radius: 10px;
		padding: 8px;
		word-break: break-all;
		color: white;
		margin-left: 10px;
		float: left;


		display: flex;
		flex-direction: column;
		// align-items: center;
		justify-content: center;

	}

	.message-text {
		word-break: break-all;
	}

	.img {
		width: 200rpx;
		height: auto;
		max-width: 300rpx;
		max-height: 400rpx;
		margin: 10upx;
	}

	.message-item {
		width: 100%;
		// flex: 1;
		display: flex;
		margin-bottom: 10px;
		// margin-left: 30%;
		float: right;

		position: relative;
		//align-items: flex-start;
		//float: right;
	}

	.message-item1 {
		width: 100%;
		// flex: 1;
		display: flex;
		margin-bottom: 10px;
		float: left;
		position: relative;

		//margin-left: 30%;
		//align-items: flex-start;
		//float: right;
	}


	.message-avatar {
		width: 40px;
		height: 40px;
		border-radius: 50%;
		margin-right: 10px;
		overflow: hidden;
	}

	.self {
		margin-left: auto;
		background-color: #e6e6ac;
		color: white;
	}

	.other {
		background-color: #e5e5ea;
	}

	.message-time {
		font-size: 12px;
		color: #999;
		margin-top: 3px;
	}

	.name-img {
		width: 90upx;
		height: 90upx;
		border-radius: 50%;
		background: #d54827;
		font-size: 36upx;
		text-align: center;
		line-height: 90upx;
		color: #fff;
		margin-left: 10upx;
		margin-right: 10upx;
		margin-top: 10upx;
	}

	.name-img1 {
		width: 90upx;
		height: 90upx;
		border-radius: 5px;
		background: #d54827;
		font-size: 36upx;
		text-align: center;
		line-height: 90upx;
		color: #fff;

	}

	.voice_icon {
		height: 34rpx;
		width: 34rpx;
		background-repeat: no-repeat;
		background-size: 100%;
	}

	.voice_icon_right {
		background-image: url('/static/chat/voice-left-3.png');
		margin-left: 10rpx;
	}

	.voice_icon_left {
		background-image: url('/static/chat/voice-right-3.png');
		margin-right: 10rpx;
	}

	.voice_icon_right_an {
		animation: voiceAn_right 1s linear alternate infinite;
	}

	.voice_icon_left_an {
		animation: voiceAn_left 1s linear alternate infinite;
	}

	@keyframes voiceAn_right {
		0% {
			background-image: url('/static/chat/voice-left-1.png');
		}

		50% {
			background-image: url('/static/chat/voice-left-2.png');
		}

		100% {
			background-image: url('/static/chat/voice-left-3.png');
		}
	}

	@keyframes voiceAn_left {
		0% {
			background-image: url('/static/chat/voice-right-1.png');
		}

		50% {
			background-image: url('/static/chat/voice-right-2.png');
		}

		100% {
			background-image: url('/static/chat/voice-right-3.png');
		}
	}


	.flex-row {
		display: flex;
		flex-direction: row;
		position: relative;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
		position: relative;
	}

	.packer-box {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 99;
		color: rgb(235, 205, 153);
		padding: 60rpx;
	}

	.packer-bg {
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: #fff;
	}

	.packer-top-box {
		width: 600rpx;
		background-color: rgb(244, 94, 77);
		text-align: center;
		margin: auto;
		transform: translateY(-160rpx);
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
		position: relative;
	}

	.sender-info {
		margin-top: 200rpx;
		justify-content: center;
		line-height: 60rpx;
		font-size: 36rpx;
	}

	.sender-avatar {
		width: 60rpx;
		height: 60rpx;
		border-radius: 10rpx;
		background-color: #fff;
		margin-right: 10rpx;
	}

	.packer-greeting {
		font-size: 48rpx;
		line-height: 60rpx;
		height: 120rpx;
		margin: 40rpx 30rpx 200rpx;
	}

	.arc-edge {
		position: relative;
	}

	.arc-edge::after {
		width: 100%;
		height: 200rpx;
		position: absolute;
		left: 0;
		top: -100rpx;
		z-index: 9;
		content: '';
		border-radius: 50%;
		background-color: rgb(244, 94, 77);
		box-shadow: 0 6rpx 6rpx 0 rgba(0, 0, 0, 0.1);
	}

	.packer-bottom-box {
		transform: translate(-50%, 0);
		width: 600rpx;
		height: 360rpx;
		border-bottom-left-radius: 30rpx;
		border-bottom-right-radius: 30rpx;
		overflow: hidden;
		position: absolute;
		bottom: calc(50% - 440rpx);
		left: 50%;
	}

	.anim-ease-in {
		animation-duration: 0.5s;
		animation-timing-function: ease-in;
		animation-fill-mode: forwards;
	}

	.anim-out-top {
		animation-name: slideOutTop;
	}

	.anim-out-bottom {
		animation-name: slideOutBottom;
	}

	.anim-fade-out {
		animation-name: fadeOut;
	}

	@keyframes fadeOut {
		from {
			opacity: 1;
		}

		to {
			opacity: 0;
		}
	}

	@keyframes slideOutTop {
		from {
			transform: translateY(-160rpx);
		}

		to {
			transform: translateY(-200%);
		}
	}

	@keyframes slideOutBottom {
		from {
			transform: translate(-50%, 0);
		}

		to {
			transform: translate(-50%, 200%);
		}
	}

	.arc-bottom-edge {
		position: relative;
	}

	.arc-bottom-edge::after {
		width: 120%;
		height: 200rpx;
		position: absolute;
		left: -10%;
		top: -100rpx;
		z-index: 8;
		content: '';
		border-radius: 50%;
		box-shadow: 0 60rpx 0 0 rgb(242, 85, 66);
	}

	.packer-bottom-bg {
		background-color: rgb(242, 85, 66);
		height: 280rpx;
		margin-top: 100rpx;
	}

	.packer-btn {
		border-radius: 50%;
		width: 200rpx;
		height: 200rpx;
		line-height: 200rpx;
		font-size: 80rpx;
		text-align: center;
		color: #333;
		background-color: rgb(235, 205, 153);
		box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.1);
	}

	.packer-btn-pos {
		transform: translateX(-50%);
		position: absolute;
		left: 50%;
		z-index: 10;
		bottom: -200rpx;
	}

	.packer-btn-front {
		position: absolute;
		top: 0;
		transform: translateZ(4px);
	}

	.packer-btn-middle {
		position: absolute;
		top: 0;
		border-radius: 50%;
		width: 200rpx;
		height: 200rpx;
		background-color: rgb(235, 180, 120);
	}

	.anim-rotate {
		margin-left: -100rpx;
		transform-style: preserve-3d;
		animation: rotate 1s linear infinite;
	}

	@keyframes rotate {
		0% {
			transform: rotateY(0deg);
		}

		100% {
			transform: rotateY(360deg);
		}
	}


	.btn-list-grid {
		padding: 20upx 0;
		display: grid;
		grid-template-columns: 1fr 1fr 1fr 1fr;
		grid-column-gap: 20upx;
		row-gap: 20upx;

		// grid-template-columns: calc(calc(100% - 10px)/2) calc(calc(100% - 10px)/2);

		.btn-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			height: 120upx;




			.btn-item-flex {
				flex: 1;
				justify-content: center;
				width: 120upx;
				height: 120upx;
				background-color: #EEE;
				border-radius: 10upx;
				display: flex;
				flex-direction: column;
				align-items: center;
				position: relative;
			}

			.icon {
				width: 50upx;
			}

			.text {
				font-size: 24upx;
				margin-top: 4upx;
			}
		}
	}

	.dirlog-box {
		width: 40%;
		background: #fff;
		border-radius: 20upx;
		padding: 10upx 30upx;
		box-shadow: 0 0 40upx #000; // 左
		box-shadow: 0 0 40upx #000; // 右
		color: #2e2e2e;
		font-weight: 300;
		position: absolute;
		right: 3%;
		top: 11%;
		z-index: 1;

		.dirlog-box1 {
			display: flex;
			padding: 30upx 10upx;

			image {
				width: 40upx;
				height: 40upx;
			}

			view {
				margin-left: 20upx;
			}
		}
	}

	.video1 {
		width: 100%;
		height: 100%;
		// top: -20px;
		// left: -5px;
		top: 0;
		// margin-left: -10px;
		z-index: 10000;
		position: fixed;
		background-color: #000000;

		.btn-close-box {
			width: 100%;
			height: 40px;
			padding: 10px 20px 10px 10px;

			top: calc(10px + (var(--status-bar-height)));
			position: fixed;

			.btn-close {
				float: right;
				width: 30px;
				height: 30px;
			}

		}

		video {
			width: 100%;
			margin-top: calc(50px + (var(--status-bar-height)));
			height: calc(100% - calc(50px + (var(--status-bar-height))));
		}
	}



	.mask-top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #dfdfdf;
		padding: 30upx;
	}

	.mask-con {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30upx;

		.mask-title {
			color: #464646;
			font-size: 30upx;
			font-weight: 300;
		}

		.mask-title1 {
			font-size: 30upx;
		}
	}

	.pup-content {
		width: 100%;
		// padding-bottom: 20upx;
		background: #999;
		// border-radius: 16rpx 16rpx 0rpx 0rpx;

		.pup-list1,
		.pup-list {
			display: flex;
			justify-content: center;
			align-items: center;
			// margin-top: 40upx;
			padding: 20upx;
			// padding-left: 24upx;
			// padding-right: 24upx;
			background: #FFFFFF;

			.tittle {
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}

			.pup-img {
				width: 24rpx;
				height: 24rpx;
				margin-left: 30upx;
			}
		}

		.pup-list1 {
			margin-top: 10px;
		}

		.pup-btn {
			width: 92%;
			height: 88rpx;
			background: #00D4E2;
			border-radius: 44rpx;
			font-weight: 500;
			font-size: 28rpx;
			color: #FFFFFF;
			text-align: center;
			padding-top: 24upx;
			position: fixed;
			bottom: 20upx;
			margin-left: 24upx;
		}
	}

	.title-wrap {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10upx 0;
		border-bottom: 2upx solid #ccc;
		margin-bottom: 20upx;
	}
</style>